-
Notifications
You must be signed in to change notification settings - Fork 49
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
feat: add more user agent app id sources #1071
Merged
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
315c35d
Added new sources for user agent app id
0marperez 464abcb
Changelog
0marperez ee1ff25
Bug fix
0marperez 073cfff
Increase test duration limit
0marperez ef09ee8
Minor fixes, rename sdkUserAgentAppId to applicationId, update applic…
0marperez 28766dc
Pull from main
0marperez e367e71
Nit fixes
0marperez ec4ca48
Pull from main
0marperez d8532e7
More nit fixes
0marperez File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
{ | ||
"id": "2e8e4fee-c462-45d2-b421-46520d06eb60", | ||
"type": "feature", | ||
"description": "Add new sources for User-Agent app id", | ||
"issues": [ | ||
"awslabs/aws-sdk-kotlin#945" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 22 additions & 0 deletions
22
...runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/useragent/ResolveUserAgent.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package aws.sdk.kotlin.runtime.config.useragent | ||
|
||
import aws.sdk.kotlin.runtime.InternalSdkApi | ||
import aws.sdk.kotlin.runtime.config.AwsSdkSetting | ||
import aws.sdk.kotlin.runtime.config.profile.AwsProfile | ||
import aws.sdk.kotlin.runtime.config.profile.sdkUserAgentAppId | ||
import aws.smithy.kotlin.runtime.config.resolve | ||
import aws.smithy.kotlin.runtime.util.LazyAsyncValue | ||
import aws.smithy.kotlin.runtime.util.PlatformProvider | ||
|
||
/** | ||
* Attempts to resolve user agent from specified sources. | ||
* @return The user agent app id if found, null if not | ||
*/ | ||
@InternalSdkApi | ||
public suspend fun resolveUserAgentAppId(platform: PlatformProvider = PlatformProvider.System, profile: LazyAsyncValue<AwsProfile>): String? = | ||
AwsSdkSetting.AwsAppId.resolve(platform) ?: profile.get().sdkUserAgentAppId |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
aws-runtime/aws-config/jvm/test/aws/sdk/kotlin/runtime/config/utils/MockPlatform.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
package aws.sdk.kotlin.runtime.config.utils | ||
|
||
import aws.smithy.kotlin.runtime.util.OperatingSystem | ||
import aws.smithy.kotlin.runtime.util.PlatformProvider | ||
import io.mockk.coEvery | ||
import io.mockk.every | ||
import io.mockk.mockk | ||
import io.mockk.slot | ||
import java.io.File | ||
|
||
internal fun mockPlatform( | ||
pathSegment: String, | ||
awsProfileEnv: String? = null, | ||
awsConfigFileEnv: String? = null, | ||
homeEnv: String? = null, | ||
awsSharedCredentialsFileEnv: String? = null, | ||
awsSdkUserAgentAppIdEnv: String? = null, | ||
homeProp: String? = null, | ||
os: OperatingSystem, | ||
): PlatformProvider { | ||
val testPlatform = mockk<PlatformProvider>() | ||
val envKeyParam = slot<String>() | ||
val propKeyParam = slot<String>() | ||
val filePath = slot<String>() | ||
|
||
every { testPlatform.filePathSeparator } returns pathSegment | ||
every { testPlatform.getenv(capture(envKeyParam)) } answers { | ||
when (envKeyParam.captured) { | ||
"AWS_PROFILE" -> awsProfileEnv | ||
"AWS_CONFIG_FILE" -> awsConfigFileEnv | ||
"HOME" -> homeEnv | ||
"AWS_SHARED_CREDENTIALS_FILE" -> awsSharedCredentialsFileEnv | ||
"AWS_SDK_UA_APP_ID" -> awsSdkUserAgentAppIdEnv | ||
else -> error(envKeyParam.captured) | ||
} | ||
} | ||
every { testPlatform.getProperty(capture(propKeyParam)) } answers { | ||
if (propKeyParam.captured == "user.home") homeProp else null | ||
} | ||
every { testPlatform.osInfo() } returns os | ||
coEvery { | ||
testPlatform.readFileOrNull(capture(filePath)) | ||
} answers { | ||
if (awsConfigFileEnv != null) { | ||
val file = if (filePath.captured.endsWith("config")) { | ||
File(awsConfigFileEnv) | ||
} else { | ||
File(awsSharedCredentialsFileEnv) | ||
} | ||
|
||
if (file.exists()) file.readBytes() else null | ||
} else { | ||
null | ||
} | ||
} | ||
|
||
return testPlatform | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
question: what changed here, is
region
no longer required?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.
The check wasn't required to begin with. I removed it because it was interfering with the
applicationId
tests. I would've had to add a region to theTestClient
from the tests even if it wasn't necessary