diff --git a/core/profiles/src/main/java/software/amazon/awssdk/profiles/ProfileFile.java b/core/profiles/src/main/java/software/amazon/awssdk/profiles/ProfileFile.java index 877e7f89080b..89ffa2b64ad2 100644 --- a/core/profiles/src/main/java/software/amazon/awssdk/profiles/ProfileFile.java +++ b/core/profiles/src/main/java/software/amazon/awssdk/profiles/ProfileFile.java @@ -31,6 +31,7 @@ import software.amazon.awssdk.profiles.internal.ProfileFileReader; import software.amazon.awssdk.utils.FunctionalUtils; import software.amazon.awssdk.utils.IoUtils; +import software.amazon.awssdk.utils.StringInputStream; import software.amazon.awssdk.utils.ToString; import software.amazon.awssdk.utils.Validate; import software.amazon.awssdk.utils.builder.SdkBuilder; @@ -233,6 +234,14 @@ public enum Type { * required fields. */ public interface Builder extends SdkBuilder { + /** + * Configure the content of the profile file. This stream will be read from and then closed when {@link #build()} is + * invoked. + */ + default Builder content(String content) { + return content(new StringInputStream(content)); + } + /** * Configure the content of the profile file. This stream will be read from and then closed when {@link #build()} is * invoked. diff --git a/core/profiles/src/main/java/software/amazon/awssdk/profiles/ProfileProperty.java b/core/profiles/src/main/java/software/amazon/awssdk/profiles/ProfileProperty.java index 97d35332ada9..4e7e760eb607 100644 --- a/core/profiles/src/main/java/software/amazon/awssdk/profiles/ProfileProperty.java +++ b/core/profiles/src/main/java/software/amazon/awssdk/profiles/ProfileProperty.java @@ -171,6 +171,12 @@ public final class ProfileProperty { */ public static final String REQUEST_MIN_COMPRESSION_SIZE_BYTES = "request_min_compression_size_bytes"; + /** + * The endpoint override to use. This may also be specified under a service-specific parent property to override the + * endpoint just for that one service. + */ + public static final String ENDPOINT_URL = "endpoint_url"; + private ProfileProperty() { } } diff --git a/core/profiles/src/main/java/software/amazon/awssdk/profiles/internal/ProfileFileReader.java b/core/profiles/src/main/java/software/amazon/awssdk/profiles/internal/ProfileFileReader.java index 3c4adae1111c..f500711eccc1 100644 --- a/core/profiles/src/main/java/software/amazon/awssdk/profiles/internal/ProfileFileReader.java +++ b/core/profiles/src/main/java/software/amazon/awssdk/profiles/internal/ProfileFileReader.java @@ -170,7 +170,10 @@ private static void readPropertyContinuationLine(ParserState state, String line) // If this is a sub-property, make sure it can be parsed correctly by the CLI. if (state.validatingContinuationsAsSubProperties) { - parsePropertyDefinition(state, line); + parsePropertyDefinition(state, line).ifPresent(p -> { + String subPropertyDefinition = state.currentPropertyBeingRead + "." + p.left(); + profileProperties.put(subPropertyDefinition, p.right()); + }); } profileProperties.put(state.currentPropertyBeingRead, newPropertyValue); diff --git a/core/profiles/src/test/java/software/amazon/awssdk/profiles/ProfileFileTest.java b/core/profiles/src/test/java/software/amazon/awssdk/profiles/ProfileFileTest.java index f4d10da43180..e827e07dbd8b 100644 --- a/core/profiles/src/test/java/software/amazon/awssdk/profiles/ProfileFileTest.java +++ b/core/profiles/src/test/java/software/amazon/awssdk/profiles/ProfileFileTest.java @@ -343,7 +343,9 @@ public void propertiesCanHaveSubProperties() { assertThat(configFileProfiles("[profile foo]\n" + "s3 =\n" + " name = value")) - .isEqualTo(profiles(profile("foo", property("s3", "\nname = value")))); + .isEqualTo(profiles(profile("foo", + property("s3", "\nname = value"), + property("s3.name", "value")))); } @Test @@ -359,7 +361,9 @@ public void subPropertiesCanHaveEmptyValues() { assertThat(configFileProfiles("[profile foo]\n" + "s3 =\n" + " name =")) - .isEqualTo(profiles(profile("foo", property("s3", "\nname =")))); + .isEqualTo(profiles(profile("foo", + property("s3", "\nname ="), + property("s3.name", "")))); } @Test @@ -385,7 +389,10 @@ public void subPropertiesCanHaveBlankLines() { " name = value\n" + "\t \n" + " name2 = value2")) - .isEqualTo(profiles(profile("foo", property("s3", "\nname = value\nname2 = value2")))); + .isEqualTo(profiles(profile("foo", + property("s3", "\nname = value\nname2 = value2"), + property("s3.name", "value"), + property("s3.name2", "value2")))); } @Test @@ -565,7 +572,7 @@ public void returnsEmptyMap_when_AwsFilesDoNotExist() { private ProfileFile configFile(String configFile) { return ProfileFile.builder() - .content(new StringInputStream(configFile)) + .content(configFile) .type(ProfileFile.Type.CONFIGURATION) .build(); } @@ -576,7 +583,7 @@ private Map configFileProfiles(String configFile) { private ProfileFile credentialFile(String credentialFile) { return ProfileFile.builder() - .content(new StringInputStream(credentialFile)) + .content(credentialFile) .type(ProfileFile.Type.CREDENTIALS) .build(); }