Skip to content
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!: Make config object immutable after client creation #1886

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

jbelkins
Copy link
Contributor

@jbelkins jbelkins commented Feb 6, 2025

Issue #

Description of changes

New/existing dependencies impact assessment, if applicable

Conventional Commits

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

@@ -19,7 +20,7 @@ class EndpointPlugin(private val serviceConfig: ServiceConfig) : Plugin {
}

override fun render(ctx: ProtocolGenerator.GenerationContext, writer: SwiftWriter) {
writer.openBlock("public class $pluginName: Plugin {", "}") {
writer.openBlock("public class \$L: \$N {", "}", pluginName, ClientRuntimeTypes.Core.Plugin) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cleanup, and used the symbol for Plugin to ensure correct imports.

"}",
serviceConfig.typeName,
) {
writer.write("clientConfiguration.endpointResolver = self.endpointResolver")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safe unwrap is unneeded & removed.

"clientConfiguration.bearerTokenIdentityResolver = \$N(token: \$N(token: \"\"))",
SmithyIdentityTypes.StaticBearerTokenIdentityResolver,
SmithyIdentityTypes.BearerTokenIdentity
)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safe unwrap is unneeded & removed. Also a little code cleanup.

writer.write("clientConfiguration.awsCredentialIdentityResolver = self.awsCredentialIdentityResolver!")
}
writer.openBlock("if self.bearerTokenIdentityResolver != nil {", "}") {
writer.write("clientConfiguration.bearerTokenIdentityResolver = self.bearerTokenIdentityResolver!")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safe unwrap is unneeded & removed. Also cleanup.

@@ -129,7 +129,7 @@ class AWSHttpProtocolServiceClient(
*/
private fun renderRegionConfigInitializer(properties: List<ConfigProperty>) {
writer.openBlock(
"public convenience init(region: \$N) throws {",
"public init(region: \$N) throws {",
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removed convenience since config is no longer a class.

}
public func configureClient(clientConfiguration: inout Config) {
clientConfiguration.region = self.region
clientConfiguration.signingRegion = self.region
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safe unwrap is unneeded & removed.

clientConfiguration.awsRetryMode,
clientConfiguration.maxAttempts
)
clientConfiguration.awsCredentialIdentityResolver = try AWSClientConfigDefaultsProvider.awsCredentialIdentityResolver()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Safe unwrap is unneeded & removed.

public protocol AWSRegionClientConfiguration {
import protocol ClientRuntime.ClientConfiguration

public protocol AWSRegionClientConfiguration: ClientConfiguration {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adding this conformance here since it is already always true, and it removes the need to specify it in the region config plugin below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant