Skip to content

Commit

Permalink
Unify codegen flags
Browse files Browse the repository at this point in the history
Unify codegen flags behind a single "awsSdkBuild" flag. This is a singular flag to toggle "AWS mode" on and off. This also updates the sdk-codegen integration tests to be use this build mode to more closely reflect actual generated SDKs.
  • Loading branch information
rcoh committed Dec 11, 2023
1 parent ee8ed55 commit c704d15
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 20 deletions.
8 changes: 0 additions & 8 deletions aws/sdk-adhoc-test/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,6 @@ fun baseTest(service: String, module: String, imports: List<String> = listOf()):
"includeFluentClient": false,
"nullabilityCheckMode": "${getNullabilityCheckMode()}"
""",
extraConfig = """
, "customizationConfig": {
"awsSdk": {
"generateReadme": false,
"requireEndpointResolver": false
}
}
""",
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ class SdkSettings private constructor(private val awsSdk: ObjectNode?) {
get() =
awsSdk?.getStringMember("partitionsConfigPath")?.orNull()?.value?.let { Paths.get(it) }

val productionSdkBuild: Boolean
get() = awsSdk?.getBooleanMember("productionSdkBuild")?.orNull()?.value ?: false
val awsSdkBuild: Boolean
get() = awsSdk?.getBooleanMember("awsSdkBuild")?.orNull()?.value ?: false

/** Path to AWS SDK integration tests */
val integrationTestPath: String
Expand All @@ -45,11 +45,10 @@ class SdkSettings private constructor(private val awsSdk: ObjectNode?) {

/** Whether to generate a README */
val generateReadme: Boolean
get() =
awsSdk?.getBooleanMember("generateReadme")?.orNull()?.value ?: false
get() = awsSdkBuild

val requireEndpointResolver: Boolean
get() = awsSdk?.getBooleanMember("requireEndpointResolver")?.orNull()?.value ?: true
get() = awsSdkBuild
}

fun ClientCodegenContext.sdkSettings() = SdkSettings.from(this.settings)
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class AwsEndpointsStdLib() : ClientCodegenDecorator {
if (partitionsCache == null) {
val partitionsJson = when (val path = sdkSettings.partitionsConfigPath) {
null -> {
if (sdkSettings.productionSdkBuild) {
PANIC("cannot use hardcoded partitions in AWS SDK production build")
if (sdkSettings.awsSdkBuild) {
PANIC("cannot use hardcoded partitions in AWS SDK build")
}
(
javaClass.getResource("/default-partitions.json")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import software.amazon.smithy.rust.codegen.core.testutil.unitTest
internal class RegionProviderConfigTest {
@Test
fun `generates a valid config`() {
awsSdkIntegrationTest(SdkCodegenIntegrationTest.model) { _ctx, crate ->
awsSdkIntegrationTest(SdkCodegenIntegrationTest.model) { _, crate ->
crate.unitTest {
rustTemplate("let conf: Option<crate::Config> = None; let _reg: Option<crate::config::Region> = conf.and_then(|c|c.region().cloned());")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ fun awsSdkIntegrationTest(
) =
clientIntegrationTest(
model,
awsIntegrationTestParams(),
params,
test = test,
)

Expand All @@ -55,8 +55,10 @@ fun awsIntegrationTestParams() = IntegrationTestParams(
.withMember(
"awsSdk",
ObjectNode.builder()
.withMember("generateReadme", false)
.withMember("awsSdkBuild", true)
.withMember("integrationTestPath", "../sdk/integration-tests")
.withMember("partitionsConfigPath", "../sdk/aws-models/sdk-endpoints.json")
.withMember("awsConfigVersion", "1")
.build(),
).build(),
)
Expand Down
3 changes: 1 addition & 2 deletions aws/sdk/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,9 @@ fun generateSmithyBuild(services: AwsServices): String {
"license": "Apache-2.0",
"customizationConfig": {
"awsSdk": {
"generateReadme": true,
"awsSdkBuild": true,
"awsConfigVersion": "$awsConfigVersion",
"defaultConfigPath": "${services.defaultConfigPath}",
"productionSdkBuild": true,
"partitionsConfigPath": "${services.partitionsConfigPath}",
"integrationTestPath": "${project.projectDir.resolve("integration-tests")}"
}
Expand Down

0 comments on commit c704d15

Please sign in to comment.