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 63bcfa99..e59684de 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 @@ class NamedConfigMapContextToSourceDataProviderTests { 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 f5f92f7b..75e0322e 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 @@ class NamedSecretContextToSourceDataProviderTests { 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 00714b9a..e517b293 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 final class ConfigUtils { rawData = decodeData(rawData); } - // In some cases we want to include properties from the default profile along with any active profiles + // In some cases we want to include properties from the default profile + // along with any active profiles // In these cases includeDefaultProfileData will be true - // If includeDefaultProfileData is false then we want to make sure that we only return properties from any active profiles + // If includeDefaultProfileData is false then we want to make sure that we + // only return properties from any active profiles - //Check the source to see if it contains any active profiles + // 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)); @@ -225,8 +227,8 @@ public final class ConfigUtils { } /* - * In the case there the data contains yaml or properties files we need to check their names to see if they - * contain any active profiles. + * In the case there the data contains yaml or properties files we need to check their + * names to see if they contain any active profiles. */ private static boolean containsDataWithProfile(Map 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 6790cca8..1e0d65ab 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 final class NamedConfigMapNormalizedSource extends NormalizedSource { } /** - * 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 7a51a4d4..3d3897b4 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 final class NamedSecretNormalizedSource extends NormalizedSource { } /** - * 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 f1dcd14d..a73c8508 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 @@ public class SourceDataEntriesProcessor extends MapPropertySource { 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"