Skip to content

Commit

Permalink
Relocate property keys with multiple profiles
Browse files Browse the repository at this point in the history
Signed-off-by: Emanuel Alves <[email protected]>
  • Loading branch information
ejba committed Sep 18, 2023
1 parent e06b7b7 commit 434f62b
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,16 @@ public ConfigSourceInterceptor getInterceptor(final ConfigSourceInterceptorConte
multipleProfileProperties
.add(new MultipleProfileProperty(name, name.substring(profileSegment.length()), profiles));
}
} else if (name.length() > 1 && name.charAt(0) == '"' && name.charAt(1) == '%') {
String segments = name.substring(name.indexOf('"', 1) + 1);
NameIterator ni = new NameIterator(name);
String profileSegment = ni.getNextSegment();
List<String> profiles = convertProfile(profileSegment.substring(1));

if (profiles.size() > 1) {
multipleProfileProperties
.add(new MultipleProfileProperty(name, segments, profiles));
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,17 @@ void multipleProfiles() {
assertEquals("5678", config.getRawValue("my.prop"));
}

@Test
void relocatePropertyKeysWithMultipleProfiles() {
SmallRyeConfig config = new SmallRyeConfigBuilder()
.withSources(config(SMALLRYE_CONFIG_PROFILE, "common", "config_ordinal", "1000"))
.withSources(config("\"%common,another\".my.prop", "1234"))
.addDefaultInterceptors()
.build();

assertEquals("1234", config.getRawValue("my.prop"));
}

@Test
void multipleProfilesDocs() {
SmallRyeConfig config = new SmallRyeConfigBuilder()
Expand Down

0 comments on commit 434f62b

Please sign in to comment.