-
Notifications
You must be signed in to change notification settings - Fork 50
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
fix: add forcePathStyle and enableAccelerate config properties back to the S3 client #1099
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
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": "256a9c00-f658-4ee8-9e02-2cf46b76a900", | ||
"type": "bugfix", | ||
"description": "Add `forcePathStyle` and `enableAccelerate` config properties back to the S3 client.", | ||
"issues": [ | ||
"awslabs/aws-sdk-kotlin#1098" | ||
] | ||
} |
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
24 changes: 24 additions & 0 deletions
24
services/s3/common/src/aws/sdk/kotlin/services/s3/internal/S3Setting.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,24 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.sdk.kotlin.services.s3.internal | ||
|
||
import aws.smithy.kotlin.runtime.config.* | ||
|
||
/** | ||
* S3 specific system settings | ||
*/ | ||
internal object S3Setting { | ||
/** | ||
* Configure whether the S3 client should uses the access point ARN AWS region to construct the regional endpoint | ||
* for the request. See [Amazon S3 access points](https://docs.aws.amazon.com/sdkref/latest/guide/feature-s3-access-point.html) | ||
*/ | ||
public val UseArnRegion: EnvironmentSetting<Boolean> = boolEnvSetting("aws.s3UseArnRegion", "AWS_S3_USE_ARN_REGION") | ||
|
||
/** | ||
* Configure whether the S3 client potentially attempts cross-Region requests. | ||
* See [Amazon S3 Multi-Region Access Points](https://docs.aws.amazon.com/sdkref/latest/guide/feature-s3-mrap.html) | ||
*/ | ||
public val DisableMultiRegionAccessPoints: EnvironmentSetting<Boolean> = boolEnvSetting("aws.s3DisableMultiRegionAccessPoints", "AWS_S3_DISABLE_MULTIREGION_ACCESS_POINTS") | ||
} |
102 changes: 102 additions & 0 deletions
102
services/s3/common/test/aws/sdk/kotlin/services/s3/internal/FinalizeConfigTest.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,102 @@ | ||
/* | ||
* Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
package aws.sdk.kotlin.services.s3.internal | ||
|
||
import aws.sdk.kotlin.runtime.config.profile.loadAwsSharedConfig | ||
import aws.sdk.kotlin.services.s3.S3Client | ||
import aws.smithy.kotlin.runtime.util.TestPlatformProvider | ||
import aws.smithy.kotlin.runtime.util.asyncLazy | ||
import kotlinx.coroutines.test.runTest | ||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
|
||
class FinalizeConfigTest { | ||
@Test | ||
fun testExplicitConfigTakesPrecedence() = runTest { | ||
val builder = S3Client.builder() | ||
builder.config.useArnRegion = false | ||
builder.config.disableMrap = true | ||
val platform = TestPlatformProvider( | ||
fs = mapOf( | ||
"/users/test/.aws/config" to "[default]\ns3_use_arn_region = true\ns3_disable_multiregion_access_points = false", | ||
), | ||
) | ||
val sharedConfig = asyncLazy { loadAwsSharedConfig(platform) } | ||
|
||
finalizeS3Config(builder, sharedConfig, platform) | ||
assertEquals(false, builder.config.useArnRegion) | ||
assertEquals(true, builder.config.disableMrap) | ||
} | ||
|
||
@Test | ||
fun testSystemProperties() = runTest { | ||
val builder = S3Client.builder() | ||
val platform = TestPlatformProvider( | ||
env = mapOf( | ||
S3Setting.UseArnRegion.envVar to "false", | ||
S3Setting.DisableMultiRegionAccessPoints.envVar to "true", | ||
), | ||
props = mapOf( | ||
S3Setting.UseArnRegion.sysProp to "true", | ||
S3Setting.DisableMultiRegionAccessPoints.sysProp to "false", | ||
), | ||
fs = mapOf( | ||
"/users/test/.aws/config" to "[default]\ns3_use_arn_region = false\ns3_disable_multiregion_access_points = true", | ||
), | ||
) | ||
val sharedConfig = asyncLazy { loadAwsSharedConfig(platform) } | ||
|
||
finalizeS3Config(builder, sharedConfig, platform) | ||
assertEquals(true, builder.config.useArnRegion) | ||
assertEquals(false, builder.config.disableMrap) | ||
} | ||
|
||
@Test | ||
fun testEnvironmentVariables() = runTest { | ||
val builder = S3Client.builder() | ||
val platform = TestPlatformProvider( | ||
env = mapOf( | ||
S3Setting.UseArnRegion.envVar to "false", | ||
S3Setting.DisableMultiRegionAccessPoints.envVar to "true", | ||
), | ||
fs = mapOf( | ||
"/users/test/.aws/config" to "[default]\ns3_use_arn_region = true\ns3_disable_multiregion_access_points = false", | ||
), | ||
) | ||
val sharedConfig = asyncLazy { loadAwsSharedConfig(platform) } | ||
|
||
finalizeS3Config(builder, sharedConfig, platform) | ||
assertEquals(false, builder.config.useArnRegion) | ||
assertEquals(true, builder.config.disableMrap) | ||
} | ||
|
||
@Test | ||
fun testProfile() = runTest { | ||
val builder = S3Client.builder() | ||
val platform = TestPlatformProvider( | ||
fs = mapOf( | ||
"/users/test/.aws/config" to "[default]\ns3_use_arn_region = true\ns3_disable_multiregion_access_points = false", | ||
), | ||
) | ||
val sharedConfig = asyncLazy { loadAwsSharedConfig(platform) } | ||
|
||
finalizeS3Config(builder, sharedConfig, platform) | ||
assertEquals(true, builder.config.useArnRegion) | ||
assertEquals(false, builder.config.disableMrap) | ||
} | ||
|
||
@Test | ||
fun testConfigPropertiesPresent() { | ||
// regression test to verify that these config properties are generated and can be set | ||
// see https://github.com/awslabs/aws-sdk-kotlin/issues/1098 | ||
val builder = S3Client.builder() | ||
builder.config.disableMrap = true | ||
builder.config.useArnRegion = true | ||
builder.config.forcePathStyle = true | ||
builder.config.enableAccelerate = true | ||
builder.config.useDualStack = true | ||
builder.config.useFips = true | ||
} | ||
} |
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.
What is this testing?
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.
That these properties don't accidentally disappear again from codegen.
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.
That's not immediately clear from the code. Can we leave a comment indicating why we have a test with no assertions?