Skip to content

Commit

Permalink
Ignore unmapped properties recursively when other properties are also…
Browse files Browse the repository at this point in the history
… ignored (#1111)
  • Loading branch information
radcortez committed Feb 6, 2024
1 parent f0070af commit edd7606
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,10 @@ void reportUnknown(final List<String> ignoredPaths) {
found.putRootValue(Boolean.TRUE);
ignoreRecursively(found);
} else {
found = ignoredProperties.findOrAdd(ignoredPath);
found.putRootValue(Boolean.TRUE);
if (!ignoredProperties.hasRootValue(ignoredPath)) {
found = ignoredProperties.findOrAdd(ignoredPath);
found.putRootValue(Boolean.TRUE);
}
}
}

Expand All @@ -164,7 +166,7 @@ void reportUnknown(final List<String> ignoredPaths) {
if (!ignoredProperties.hasRootValue(name)) {
ConfigValue configValue = config.getConfigValue(name);
// TODO - https://github.com/quarkusio/quarkus/issues/38479
if (configValue.getSourceName().equals(EnvConfigSource.NAME)) {
if (configValue.getSourceName().startsWith(EnvConfigSource.NAME)) {
continue;
}
problems.add(new Problem(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2538,4 +2538,35 @@ interface Datasource {
String name();
}
}

@Test
void ignorePathsRecursive() {
SmallRyeConfig config = new SmallRyeConfigBuilder()
.withMappingIgnore("ignore.**")
.withMappingIgnore("ignore.nested.nested.ignore")
.withSources(config(
"ignore.ignore", "ignore",
"ignore.nested.something", "ignore",
"ignore.nested.nested.ignore", "ignore"))
.withMapping(IgnorePathsRecursive.class)
.build();

assertNotNull(config.getConfigMapping(IgnorePathsRecursive.class));

config = new SmallRyeConfigBuilder()
.withMappingIgnore("ignore.nested.nested.ignore")
.withMappingIgnore("ignore.**")
.withSources(config(
"ignore.ignore", "ignore",
"ignore.nested.something", "ignore",
"ignore.nested.nested.ignore", "ignore"))
.withMapping(IgnorePathsRecursive.class)
.build();

assertNotNull(config.getConfigMapping(IgnorePathsRecursive.class));
}

@ConfigMapping(prefix = "ignore")
interface IgnorePathsRecursive {
}
}

0 comments on commit edd7606

Please sign in to comment.