diff --git a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/NamedConfigMapContextToSourceDataProviderTests.java b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/NamedConfigMapContextToSourceDataProviderTests.java index 63bcfa994..e59684de1 100644 --- a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/NamedConfigMapContextToSourceDataProviderTests.java +++ b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/NamedConfigMapContextToSourceDataProviderTests.java @@ -168,7 +168,8 @@ void matchIncludeSingleProfile() { ConfigUtils.Prefix.DEFAULT, true, true); MockEnvironment environment = new MockEnvironment(); environment.setActiveProfiles("with-profile"); - KubernetesClientConfigContext context = new KubernetesClientConfigContext(api, source, NAMESPACE, environment, false); + KubernetesClientConfigContext context = new KubernetesClientConfigContext(api, source, NAMESPACE, environment, + false); KubernetesClientContextToSourceData data = new NamedConfigMapContextToSourceDataProvider().get(); SourceData sourceData = data.apply(context); diff --git a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/NamedSecretContextToSourceDataProviderTests.java b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/NamedSecretContextToSourceDataProviderTests.java index f5f92f7b1..75e0322e9 100644 --- a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/NamedSecretContextToSourceDataProviderTests.java +++ b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/NamedSecretContextToSourceDataProviderTests.java @@ -221,7 +221,8 @@ void matchIncludeSingleProfile() { true, true); MockEnvironment environment = new MockEnvironment(); environment.addActiveProfile("with-profile"); - KubernetesClientConfigContext context = new KubernetesClientConfigContext(api, source, NAMESPACE, environment, false); + KubernetesClientConfigContext context = new KubernetesClientConfigContext(api, source, NAMESPACE, environment, + false); KubernetesClientContextToSourceData data = new NamedSecretContextToSourceDataProvider().get(); SourceData sourceData = data.apply(context); diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtils.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtils.java index 00714b9a9..e517b293d 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtils.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtils.java @@ -205,11 +205,13 @@ public static MultipleSourcesContainer processNamedData(List source.contains("-" + p) || "default".equals(p)); @@ -225,8 +227,8 @@ public static MultipleSourcesContainer processNamedData(List rawData, String[] activeProfiles) { return rawData.keySet().stream().anyMatch( diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NamedConfigMapNormalizedSource.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NamedConfigMapNormalizedSource.java index 6790cca8c..1e0d65abc 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NamedConfigMapNormalizedSource.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NamedConfigMapNormalizedSource.java @@ -59,8 +59,8 @@ public boolean profileSpecificSources() { } /** - * append or not the active profiles to the name of the generated source. - * At the moment this is true only for config server generated sources. + * append or not the active profiles to the name of the generated source. At the + * moment this is true only for config server generated sources. */ public boolean appendProfileToName() { return appendProfileToName; diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NamedSecretNormalizedSource.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NamedSecretNormalizedSource.java index 7a51a4d4f..3d3897b4a 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NamedSecretNormalizedSource.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/NamedSecretNormalizedSource.java @@ -54,8 +54,8 @@ public boolean profileSpecificSources() { } /** - * append or not the active profiles to the name of the generated source. - * At the moment this is true only for config server generated sources. + * append or not the active profiles to the name of the generated source. At the + * moment this is true only for config server generated sources. */ public boolean appendProfileToName() { return appendProfileToName; diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessor.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessor.java index f1dcd14d6..a73c8508f 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessor.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessor.java @@ -104,10 +104,14 @@ record WeightedEntry(Map.Entry entry, int weight) { String applicationName = ConfigUtils.getApplicationName(environment, "", ""); String[] activeProfiles = environment.getActiveProfiles(); - // In some cases we want to include the properties from the default profile along with any properties from any active profiles - // In this case includeDefaultProfileData will be true or the active profile will be default - // In the case where includeDefaultProfileData is false we only want to include the properties from the active profiles - boolean includeDataEntry = includeDefaultProfileData || Arrays.asList(environment.getActiveProfiles()).contains("default"); + // In some cases we want to include the properties from the default profile along + // with any properties from any active profiles + // In this case includeDefaultProfileData will be true or the active profile will + // be default + // In the case where includeDefaultProfileData is false we only want to include + // the properties from the active profiles + boolean includeDataEntry = includeDefaultProfileData + || Arrays.asList(environment.getActiveProfiles()).contains("default"); // the order here is important, first has to come "application.yaml" and then // "application-dev.yaml"