From 0358783d5d9fd57cf4e5889f4f0c127c56171f22 Mon Sep 17 00:00:00 2001 From: Russell Cohen Date: Thu, 14 Dec 2023 15:54:13 -0500 Subject: [PATCH] CR feedback --- .../amazon/smithy/rustsdk/SdkSettings.kt | 47 +++++++++++++++++-- .../amazon/smithy/rustsdk/TestUtil.kt | 2 +- 2 files changed, 45 insertions(+), 4 deletions(-) diff --git a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkSettings.kt b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkSettings.kt index ec5114be6b3..859df771c8d 100644 --- a/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkSettings.kt +++ b/aws/sdk-codegen/src/main/kotlin/software/amazon/smithy/rustsdk/SdkSettings.kt @@ -10,14 +10,55 @@ import software.amazon.smithy.rust.codegen.core.smithy.CoreRustSettings import software.amazon.smithy.rust.codegen.core.util.orNull import java.nio.file.Path import java.nio.file.Paths +import java.util.logging.Logger /** * SDK-specific settings within the Rust codegen `customizationConfig.awsSdk` object. */ class SdkSettings private constructor(private val awsSdk: ObjectNode?) { + private fun warnOnUnusedProperties() { + if (awsSdk == null) { + return + } + val logger = Logger.getLogger("SdkSettings") + if (awsSdk.getMember("generateReadme").isPresent) { + logger.warning( + "`generateReadme` parameter is now ignored. Readmes are now only generated when " + + "`awsSdkBuild` is set to `true`. You can use `suppressReadme` to explicitly suppress the readme in that case.", + ) + } + + if (awsSdk.getMember("requireEndpointResolver").isPresent) { + logger.warning( + "`requireEndpointResolver` is no a no-op and you may remove it from your configuration. " + + "An endpoint resolver is only required when `awsSdkBuild` is set to true.", + ) + } + } companion object { - fun from(coreRustSettings: CoreRustSettings): SdkSettings = - SdkSettings(coreRustSettings.customizationConfig?.getObjectMember("awsSdk")?.orNull()) + fun from(coreRustSettings: CoreRustSettings): SdkSettings { + val settings = SdkSettings(coreRustSettings.customizationConfig?.getObjectMember("awsSdk")?.orNull()) + if (shouldPrintWarning()) { + settings.warnOnUnusedProperties() + warningPrinted() + } + return settings + } + + @Volatile + var warningPrinted = false + + private fun warningPrinted() { + synchronized(this) { + this.warningPrinted = true + } + } + + private fun shouldPrintWarning(): Boolean { + synchronized(this) { + return !this.warningPrinted + } + } } /** Path to the `sdk-default-configuration.json` config file */ @@ -38,7 +79,7 @@ class SdkSettings private constructor(private val awsSdk: ObjectNode?) { get() = awsSdk?.getStringMember("integrationTestPath")?.orNull()?.value ?: "aws/sdk/integration-tests" - /** Version number of the `aws-config` crate */ + /** Version number of the `aws-config` crate. This is used to set the dev-dependency when generating readme's */ val awsConfigVersion: String? get() = awsSdk?.getStringMember("awsConfigVersion")?.orNull()?.value diff --git a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt index bf1dc5aece6..231eb8e0aa5 100644 --- a/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt +++ b/aws/sdk-codegen/src/test/kotlin/software/amazon/smithy/rustsdk/TestUtil.kt @@ -58,7 +58,7 @@ fun awsIntegrationTestParams() = IntegrationTestParams( .withMember("awsSdkBuild", true) .withMember("suppressReadme", true) .withMember("integrationTestPath", "../sdk/integration-tests") - .withMember("partitionsConfigPath", "../sdk/aws-models/sdk-endpoints.json") + .withMember("partitionsConfigPath", "../sdk/aws-models/sdk-partitions.json") .build(), ).build(), )