-
Notifications
You must be signed in to change notification settings - Fork 55
feat(rt): credential providers redux #469
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |
| /** | ||
| * Returns the current result if not null or computes it by invoking [fn] | ||
| */ | ||
| private inline fun LeafProviderResult?.unwrapOrElse(fn: () -> LeafProviderResult): LeafProviderResult = when (this) { | ||
| null -> fn() | ||
| else -> this | ||
| } | ||
|
|
||
| /** | ||
| * Return current result if not null, otherwise use the result from calling [fn] | ||
| */ | ||
| private inline fun LeafProviderResult?.orElse(fn: () -> LeafProviderResult?): LeafProviderResult? = when (this) { | ||
| null -> fn() | ||
| else -> this | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comment: I don't quite understand why these functions are necessary over the built-in Elvis operator. Looking at the call site, I see:
return webIdentityTokenCreds()
.orElse(::ssoCreds)
.unwrapOrElse(::staticCreds)
.unwrap()Can't this be simplified to:
return (webIdentityTokenCreds() ?: ssoCreds() ?: staticCreds()).unwrap()There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't recall other than it was actually you that liked this change originally. It's a matter of taste really as changing it back to elvis operator will require throwing the configuration exceptions in each function vs returning an error.
I'm going to leave it since it's already been tested and we've already reviewed. If we add more leaf providers at some point we can revisit
| // FIXME - note this won't work until https://github.com/awslabs/aws-crt-java/issues/252 is resolved | ||
| source = builder.source?.let { CredentialsProviderCrtProxy(it) } | ||
| } | ||
| private var cachedCredentials = CachedValue<Credentials>(null, bufferTime = refreshBufferWindow, clock) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Could be val.
build.gradle.kts
Outdated
| // generated sts/sso credential providers have quite a few warnings | ||
| val optOutWErrorProjects = setOf("aws-config") | ||
|
|
||
| subprojects { | ||
| tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { | ||
| kotlinOptions.allWarningsAsErrors = true | ||
| if (name !in optOutWErrorProjects) { | ||
| // FIXME - this is NOT lazily evaluated | ||
| tasks.withType<org.jetbrains.kotlin.gradle.tasks.KotlinCompile> { | ||
| kotlinOptions.allWarningsAsErrors = true | ||
| } | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rather than maintaining a denylist, wouldn't it be simpler to turn off allWarningsAsErrors directly in aws-config's build file similar to what we do for dokka-aws?
services/build.gradle.kts
Outdated
| "aws.sdk.kotlin.runtime.InternalSdkApi", | ||
| "aws.sdk.kotlin.runtime.InternalSdkApi" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Removed trailing comma.
|
Kudos, SonarCloud Quality Gate passed!
|
|
A new generated diff is ready to view: __generated-main...__generated-feat-cred-providers |








Issue #
closes #355
closes #298
closes #461
closes #419
closes #357
closes #252
Description of changes
By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.