Skip to content

Commit 0a392c7

Browse files
lauzadisianbotsf
andauthored
misc!: v1.2.0 (#1297)
* fix: apply clock skew interceptor to clients created via `invoke` (#1284) * Add new changelog * Upgrade Kotlin version to match smithy-kotlin --------- Co-authored-by: Ian Botsford <[email protected]>
1 parent 773cab3 commit 0a392c7

File tree

10 files changed

+70
-56
lines changed

10 files changed

+70
-56
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"id": "811e504c-89f0-44e3-8216-5024ce6657ac",
3+
"type": "misc",
4+
"description": "⚠️ **IMPORTANT**: Upgrade to latest versions of OkHttp, Okio, Kotlin",
5+
"requiresMinorVersionBump": true
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"id": "f164451a-1adc-4220-9a7d-1765959c23d3",
3+
"type": "bugfix",
4+
"description": "⚠️ **IMPORTANT**: Apply clock skew interceptor to clients created via `invoke`",
5+
"issues": [
6+
"awslabs/aws-sdk-kotlin#1211"
7+
],
8+
"requiresMinorVersionBump": true
9+
}

aws-runtime/aws-config/api/aws-config.api

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -215,12 +215,11 @@ public final class aws/sdk/kotlin/runtime/auth/credentials/internal/ManagedCrede
215215
public static final fun manage (Laws/smithy/kotlin/runtime/auth/awscredentials/CloseableCredentialsProvider;)Laws/smithy/kotlin/runtime/auth/awscredentials/CredentialsProvider;
216216
}
217217

218-
public abstract class aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactory : aws/smithy/kotlin/runtime/client/SdkClientFactory {
218+
public abstract class aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactory : aws/smithy/kotlin/runtime/client/AbstractSdkClientFactory {
219219
public fun <init> ()V
220-
protected fun finalizeConfig (Laws/smithy/kotlin/runtime/client/SdkClient$Builder;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
220+
protected fun finalizeEnvironmentalConfig (Laws/smithy/kotlin/runtime/client/SdkClient$Builder;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Laws/smithy/kotlin/runtime/util/LazyAsyncValue;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
221221
public final fun fromEnvironment (Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;)Ljava/lang/Object;
222222
public static synthetic fun fromEnvironment$default (Laws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactory;Lkotlin/jvm/functions/Function1;Lkotlin/coroutines/Continuation;ILjava/lang/Object;)Ljava/lang/Object;
223-
public fun invoke (Lkotlin/jvm/functions/Function1;)Laws/smithy/kotlin/runtime/client/SdkClient;
224223
}
225224

226225
public final class aws/sdk/kotlin/runtime/config/AwsSdkSetting {

aws-runtime/aws-config/common/src/aws/sdk/kotlin/runtime/config/AbstractAwsSdkClientFactory.kt

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,7 @@ import aws.sdk.kotlin.runtime.region.resolveRegion
1919
import aws.sdk.kotlin.runtime.region.resolveSigV4aSigningRegionSet
2020
import aws.smithy.kotlin.runtime.ExperimentalApi
2121
import aws.smithy.kotlin.runtime.auth.awscredentials.SigV4aClientConfig
22-
import aws.smithy.kotlin.runtime.client.RetryStrategyClientConfig
23-
import aws.smithy.kotlin.runtime.client.SdkClient
24-
import aws.smithy.kotlin.runtime.client.SdkClientConfig
25-
import aws.smithy.kotlin.runtime.client.SdkClientFactory
22+
import aws.smithy.kotlin.runtime.client.*
2623
import aws.smithy.kotlin.runtime.client.config.ClientSettings
2724
import aws.smithy.kotlin.runtime.client.config.CompressionClientConfig
2825
import aws.smithy.kotlin.runtime.config.resolve
@@ -46,7 +43,7 @@ public abstract class AbstractAwsSdkClientFactory<
4643
TConfigBuilder,
4744
TClient : SdkClient,
4845
TClientBuilder : SdkClient.Builder<TConfig, TConfigBuilder, TClient>,
49-
> : SdkClientFactory<TConfig, TConfigBuilder, TClient, TClientBuilder>
46+
> : AbstractSdkClientFactory<TConfig, TConfigBuilder, TClient, TClientBuilder>()
5047
where TConfig : SdkClientConfig,
5148
TConfig : AwsSdkClientConfig,
5249
TConfigBuilder : SdkClientConfig.Builder<TConfig>,
@@ -97,15 +94,16 @@ public abstract class AbstractAwsSdkClientFactory<
9794
config.sigV4aSigningRegionSet ?: resolveSigV4aSigningRegionSet(platform, profile)
9895
}
9996

100-
finalizeConfig(builder, sharedConfig, profile)
97+
finalizeConfig(builder)
98+
finalizeEnvironmentalConfig(builder, sharedConfig, profile)
10199
}
102100
return builder.build()
103101
}
104102

105103
/**
106104
* Inject any client-specific config.
107105
*/
108-
protected open suspend fun finalizeConfig(
106+
protected open suspend fun finalizeEnvironmentalConfig(
109107
builder: TClientBuilder,
110108
sharedConfig: LazyAsyncValue<AwsSharedConfig>,
111109
activeProfile: LazyAsyncValue<AwsProfile>,

codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/AwsServiceConfigIntegration.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,13 @@ class AwsServiceConfigIntegration : KotlinIntegration {
121121
override val sectionWriters: List<SectionWriterBinding> =
122122
listOf(
123123
SectionWriterBinding(ServiceClientGenerator.Sections.CompanionObject, ServiceClientCompanionObjectWriter()),
124+
SectionWriterBinding(ServiceClientGenerator.Sections.CompanionObject.SuperTypes) { writer, _ ->
125+
writer.write(
126+
"#T<Config, Config.Builder, #T, Builder>()",
127+
AwsRuntimeTypes.Config.AbstractAwsSdkClientFactory,
128+
writer.getContextValue(ServiceClientGenerator.Sections.CompanionObject.ServiceSymbol),
129+
)
130+
},
124131
)
125132

126133
override fun additionalServiceConfigProps(ctx: CodegenContext): List<ConfigProperty> = buildList {

codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriter.kt

Lines changed: 16 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@
55
package aws.sdk.kotlin.codegen
66

77
import software.amazon.smithy.kotlin.codegen.core.*
8-
import software.amazon.smithy.kotlin.codegen.integration.SectionWriter
9-
import software.amazon.smithy.kotlin.codegen.lang.KotlinTypes
8+
import software.amazon.smithy.kotlin.codegen.integration.AppendingSectionWriter
9+
import software.amazon.smithy.kotlin.codegen.integration.SectionId
1010
import software.amazon.smithy.kotlin.codegen.rendering.ServiceClientGenerator
1111
import software.amazon.smithy.kotlin.codegen.utils.toPascalCase
1212

@@ -15,38 +15,27 @@ import software.amazon.smithy.kotlin.codegen.utils.toPascalCase
1515
*
1616
* Includes the ability to extend the config finalizer, which by default handles resolution of endpoint url config.
1717
*/
18-
class ServiceClientCompanionObjectWriter : SectionWriter {
19-
override fun write(writer: KotlinWriter, previousValue: String?) {
20-
val serviceSymbol = writer.getContextValue(ServiceClientGenerator.Sections.CompanionObject.ServiceSymbol)
18+
class ServiceClientCompanionObjectWriter : AppendingSectionWriter {
19+
/**
20+
* The [SectionId] used for rendering the `finalizeEnvironmentalConfig` method body.
21+
*/
22+
object FinalizeEnvironmentalConfig : SectionId
2123

24+
override fun append(writer: KotlinWriter) {
25+
val funName = "finalizeEnvironmentalConfig"
26+
writer.write("")
2227
writer.withBlock(
23-
"public companion object : #T<Config, Config.Builder, #T, Builder>() {",
24-
"}",
25-
AwsRuntimeTypes.Config.AbstractAwsSdkClientFactory,
26-
serviceSymbol,
27-
) {
28-
writeBuilder()
29-
write("")
30-
31-
writeFinalizeConfig()
32-
}
33-
}
34-
35-
private fun KotlinWriter.writeBuilder() {
36-
write("@#T", KotlinTypes.Jvm.JvmStatic)
37-
write("override fun builder(): Builder = Builder()")
38-
}
39-
40-
private fun KotlinWriter.writeFinalizeConfig() {
41-
withBlock(
42-
"override suspend fun finalizeConfig(builder: Builder, sharedConfig: #1T<#2T>, activeProfile: #1T<#3T>) {",
28+
"override suspend fun #1L(builder: Builder, sharedConfig: #2T<#3T>, activeProfile: #2T<#4T>) {",
4329
"}",
30+
funName,
4431
RuntimeTypes.Core.Utils.LazyAsyncValue,
4532
AwsRuntimeTypes.Config.Profile.AwsSharedConfig,
4633
AwsRuntimeTypes.Config.Profile.AwsProfile,
4734
) {
48-
writeResolveEndpointUrl()
49-
declareSection(ServiceClientGenerator.Sections.FinalizeConfig)
35+
declareSection(FinalizeEnvironmentalConfig) {
36+
write("super.#L(builder, sharedConfig, activeProfile)", funName)
37+
writeResolveEndpointUrl()
38+
}
5039
}
5140
}
5241

codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/AccountIdEndpointBuiltinCustomization.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
package aws.sdk.kotlin.codegen.customization
66

77
import aws.sdk.kotlin.codegen.AwsRuntimeTypes
8+
import aws.sdk.kotlin.codegen.ServiceClientCompanionObjectWriter
89
import aws.sdk.kotlin.codegen.endpoints.AwsBuiltins
910
import software.amazon.smithy.kotlin.codegen.KotlinSettings
1011
import software.amazon.smithy.kotlin.codegen.core.CodegenContext
@@ -13,7 +14,6 @@ import software.amazon.smithy.kotlin.codegen.integration.KotlinIntegration
1314
import software.amazon.smithy.kotlin.codegen.integration.SectionWriterBinding
1415
import software.amazon.smithy.kotlin.codegen.model.expectShape
1516
import software.amazon.smithy.kotlin.codegen.model.getEndpointRules
16-
import software.amazon.smithy.kotlin.codegen.rendering.ServiceClientGenerator
1717
import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigProperty
1818
import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigPropertyType
1919
import software.amazon.smithy.model.Model
@@ -42,7 +42,12 @@ class AccountIdEndpointBuiltinCustomization : KotlinIntegration {
4242
}
4343

4444
override val sectionWriters: List<SectionWriterBinding>
45-
get() = listOf(SectionWriterBinding(ServiceClientGenerator.Sections.FinalizeConfig, resolveAccountIdEndpointModeSectionWriter))
45+
get() = listOf(
46+
SectionWriterBinding(
47+
ServiceClientCompanionObjectWriter.FinalizeEnvironmentalConfig,
48+
resolveAccountIdEndpointModeSectionWriter,
49+
),
50+
)
4651

4752
private val resolveAccountIdEndpointModeSectionWriter = AppendingSectionWriter { writer ->
4853
writer.write(

codegen/aws-sdk-codegen/src/main/kotlin/aws/sdk/kotlin/codegen/customization/s3/ClientConfigIntegration.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
*/
55
package aws.sdk.kotlin.codegen.customization.s3
66

7+
import aws.sdk.kotlin.codegen.ServiceClientCompanionObjectWriter
78
import software.amazon.smithy.kotlin.codegen.KotlinSettings
89
import software.amazon.smithy.kotlin.codegen.core.CodegenContext
910
import software.amazon.smithy.kotlin.codegen.integration.AppendingSectionWriter
@@ -12,7 +13,6 @@ import software.amazon.smithy.kotlin.codegen.integration.SectionWriterBinding
1213
import software.amazon.smithy.kotlin.codegen.lang.KotlinTypes
1314
import software.amazon.smithy.kotlin.codegen.model.buildSymbol
1415
import software.amazon.smithy.kotlin.codegen.model.expectShape
15-
import software.amazon.smithy.kotlin.codegen.rendering.ServiceClientGenerator
1616
import software.amazon.smithy.kotlin.codegen.rendering.util.ConfigProperty
1717
import software.amazon.smithy.model.Model
1818
import software.amazon.smithy.model.shapes.ServiceShape
@@ -96,7 +96,12 @@ class ClientConfigIntegration : KotlinIntegration {
9696
)
9797

9898
override val sectionWriters: List<SectionWriterBinding>
99-
get() = listOf(SectionWriterBinding(ServiceClientGenerator.Sections.FinalizeConfig, finalizeS3ConfigWriter))
99+
get() = listOf(
100+
SectionWriterBinding(
101+
ServiceClientCompanionObjectWriter.FinalizeEnvironmentalConfig,
102+
finalizeS3ConfigWriter,
103+
),
104+
)
100105

101106
// add S3-specific config finalization
102107
private val finalizeS3ConfigWriter = AppendingSectionWriter { writer ->

codegen/aws-sdk-codegen/src/test/kotlin/aws/sdk/kotlin/codegen/ServiceClientCompanionObjectWriterTest.kt

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,18 +23,14 @@ class ServiceClientCompanionObjectWriterTest {
2323
ServiceClientCompanionObjectWriter().write(writer, null)
2424

2525
val expected = """
26-
public companion object : AbstractAwsSdkClientFactory<Config, Config.Builder, TestGeneratorClient, Builder>() {
27-
@JvmStatic
28-
override fun builder(): Builder = Builder()
29-
30-
override suspend fun finalizeConfig(builder: Builder, sharedConfig: LazyAsyncValue<AwsSharedConfig>, activeProfile: LazyAsyncValue<AwsProfile>) {
31-
builder.config.endpointUrl = builder.config.endpointUrl ?: resolveEndpointUrl(
32-
sharedConfig,
33-
"TestGenerator",
34-
"TEST_GENERATOR",
35-
"test_generator",
36-
)
37-
}
26+
override suspend fun finalizeEnvironmentalConfig(builder: Builder, sharedConfig: LazyAsyncValue<AwsSharedConfig>, activeProfile: LazyAsyncValue<AwsProfile>) {
27+
super.finalizeEnvironmentalConfig(builder, sharedConfig, activeProfile)
28+
builder.config.endpointUrl = builder.config.endpointUrl ?: resolveEndpointUrl(
29+
sharedConfig,
30+
"TestGenerator",
31+
"TEST_GENERATOR",
32+
"test_generator",
33+
)
3834
}
3935
""".trimIndent()
4036

gradle/libs.versions.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[versions]
2-
kotlin-version = "1.9.21"
2+
kotlin-version = "1.9.23"
33
dokka-version = "1.9.10"
44

55
aws-kotlin-repo-tools-version = "0.4.0"
@@ -9,8 +9,8 @@ coroutines-version = "1.7.3"
99
atomicfu-version = "0.23.1"
1010

1111
# smithy-kotlin codegen and runtime are versioned separately
12-
smithy-kotlin-runtime-version = "1.1.5"
13-
smithy-kotlin-codegen-version = "0.31.5"
12+
smithy-kotlin-runtime-version = "1.2.1"
13+
smithy-kotlin-codegen-version = "0.32.1"
1414

1515
# codegen
1616
smithy-version = "1.47.0"

0 commit comments

Comments
 (0)