cleanup for config server (#1615)

This commit is contained in:
erabii
2024-03-29 21:37:09 +02:00
committed by GitHub
parent fdb51efa58
commit 5b201f0b01
2 changed files with 8 additions and 16 deletions

View File

@@ -117,16 +117,6 @@ public final class KubernetesClientConfigUtils {
includeDefaultProfileData);
}
static MultipleSourcesContainer secretsDataByName(CoreV1Api coreV1Api, String namespace,
LinkedHashSet<String> sourceNames, Environment environment) {
return secretsDataByName(coreV1Api, namespace, sourceNames, environment, true);
}
static MultipleSourcesContainer configMapsDataByName(CoreV1Api coreV1Api, String namespace,
LinkedHashSet<String> sourceNames, Environment environment) {
return configMapsDataByName(coreV1Api, namespace, sourceNames, environment, true);
}
/**
* <pre>
* 1. read all config maps in the provided namespace

View File

@@ -194,11 +194,11 @@ public final class ConfigUtils {
// processed before profile based sources. This way, we replicate that
// "application-dev.yaml"
// overrides properties from "application.yaml"
sourceNames.forEach(source -> {
StrippedSourceContainer stripped = hashByName.get(source);
sourceNames.forEach(sourceName -> {
StrippedSourceContainer stripped = hashByName.get(sourceName);
if (stripped != null) {
LOG.debug("Found source with name : '" + source + " in namespace: '" + namespace + "'");
foundSourceNames.add(source);
LOG.debug("Found source with name : '" + sourceName + " in namespace: '" + namespace + "'");
foundSourceNames.add(sourceName);
// see if data is a single yaml/properties file and if it needs decoding
Map<String, String> rawData = stripped.data();
if (decode) {
@@ -214,7 +214,8 @@ public final class ConfigUtils {
// Check the source to see if it contains any active profiles
boolean containsActiveProfile = environment.getActiveProfiles().length == 0
|| Arrays.stream(environment.getActiveProfiles())
.anyMatch(p -> source.contains("-" + p) || "default".equals(p));
.anyMatch(activeProfile -> sourceName.endsWith("-" + activeProfile)
|| "default".equals(activeProfile));
if (includeDefaultProfileData || containsActiveProfile
|| containsDataWithProfile(rawData, environment.getActiveProfiles())) {
data.putAll(SourceDataEntriesProcessor.processAllEntries(rawData == null ? Map.of() : rawData,
@@ -232,7 +233,8 @@ public final class ConfigUtils {
*/
private static boolean containsDataWithProfile(Map<String, String> rawData, String[] activeProfiles) {
return rawData.keySet().stream().anyMatch(
key -> Arrays.stream(activeProfiles).anyMatch(p -> key.contains("-" + p) || "default".equals(p)));
key -> Arrays.stream(activeProfiles).anyMatch(activeProfile -> key.contains("-" + activeProfile)
|| "default".equals(activeProfile)));
}
/**