Skip to content

Commit

Permalink
CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
rcoh committed Dec 20, 2023
1 parent d89cbb0 commit d4771a6
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,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(),
)
Expand Down

0 comments on commit d4771a6

Please sign in to comment.