Skip to content

Commit fdb5b45

Browse files
committed
chore(codegen): populate default hostname and variant in PartitionHash
1 parent 94e3ea0 commit fdb5b45

File tree

1 file changed

+11
-13
lines changed
  • codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen

1 file changed

+11
-13
lines changed

codegen/smithy-aws-typescript-codegen/src/main/java/software/amazon/smithy/aws/typescript/codegen/EndpointGenerator.java

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
import software.amazon.smithy.typescript.codegen.TypeScriptDependency;
3535
import software.amazon.smithy.typescript.codegen.TypeScriptWriter;
3636
import software.amazon.smithy.utils.IoUtils;
37-
import software.amazon.smithy.utils.OptionalUtils;
3837
import software.amazon.smithy.utils.SmithyInternalApi;
3938

4039
/**
@@ -143,18 +142,17 @@ private void writePartitionHash() {
143142
}
144143
});
145144
writer.write("regionRegex: $S,", partition.regionRegex);
146-
OptionalUtils.ifPresentOrElse(partition.getPartitionEndpoint(),
147-
endpoint -> writer.write("endpoint: $S,", endpoint),
148-
// TODO: Remove hostname after fully switching to variants.
149-
() -> writer.write("hostname: $S,", partition.hostnameTemplate));
150-
List<Node> variants = partition.getVariants();
151-
if (!variants.isEmpty()) {
152-
writer.openBlock("variants: [", "],", () -> {
153-
variants.forEach(variant -> {
154-
writer.write("$L, ", Node.prettyPrintJson(variant));
155-
});
145+
146+
// TODO: Remove hostname after fully switching to variants.
147+
writer.write("hostname: $S,", partition.hostnameTemplate);
148+
writer.openBlock("variants: [", "],", () -> {
149+
partition.getVariants().forEach(variant -> {
150+
writer.write("$L, ", Node.prettyPrintJson(variant));
156151
});
157-
}
152+
});
153+
154+
partition.getPartitionEndpoint().ifPresent(
155+
endpoint -> writer.write("endpoint: $S,", endpoint));
158156
});
159157
});
160158
});
@@ -275,8 +273,8 @@ List<Node> getVariants() {
275273
hostname = hostname.replace("{dnsSuffix}", dnsSuffix);
276274
allVariants.add(variantNode.withMember("hostname", hostname).withoutMember("dnsSuffix"));
277275
});
278-
allVariants.add(getDefaultVariant(hostnameTemplate));
279276
}
277+
allVariants.add(getDefaultVariant(hostnameTemplate));
280278

281279
return allVariants;
282280
}

0 commit comments

Comments
 (0)