From d6e7e5924e2b00f46d2dc0c1e02e36114d14356a Mon Sep 17 00:00:00 2001 From: Ryan Baxter Date: Thu, 21 Oct 2021 17:08:01 -0400 Subject: [PATCH] Resolve merge conflicts from 2.0.x branch --- ...figMapIncludeProfileSpecificSourcesTests.java | 6 ++++-- .../commons/config/AbstractConfigProperties.java | 1 + .../config/ConfigMapConfigProperties.java | 8 ++++---- .../kubernetes/commons/config/ConfigUtils.java | 2 +- .../config/ConfigMapConfigPropertiesTests.java | 16 ++++++++-------- .../KubernetesConfigServerAutoConfiguration.java | 4 ++-- .../KubernetesEnvironmentRepositoryTests.java | 6 +++--- ...apWithIncludeProfileSpecificSourcesTests.java | 8 +++++--- 8 files changed, 28 insertions(+), 23 deletions(-) diff --git a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapIncludeProfileSpecificSourcesTests.java b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapIncludeProfileSpecificSourcesTests.java index 88127664..12c1d26d 100644 --- a/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapIncludeProfileSpecificSourcesTests.java +++ b/spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapIncludeProfileSpecificSourcesTests.java @@ -37,8 +37,10 @@ import org.springframework.test.web.reactive.server.WebTestClient; * @author wind57 */ @ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = IncludeProfileSpecificSourcesApp.class, - properties = { "spring.cloud.bootstrap.name=include-profile-specific-sources", "include.profile.specific.sources=true" }) +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + classes = IncludeProfileSpecificSourcesApp.class, + properties = { "spring.cloud.bootstrap.name=include-profile-specific-sources", + "include.profile.specific.sources=true" }) @AutoConfigureWebTestClient @ActiveProfiles("dev") class KubernetesClientConfigMapIncludeProfileSpecificSourcesTests { diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/AbstractConfigProperties.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/AbstractConfigProperties.java index 4797b789..8538d4d6 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/AbstractConfigProperties.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/AbstractConfigProperties.java @@ -76,4 +76,5 @@ public abstract class AbstractConfigProperties { public void setIncludeProfileSpecificSources(boolean includeProfileSpecificSources) { this.includeProfileSpecificSources = includeProfileSpecificSources; } + } diff --git a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigProperties.java b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigProperties.java index 4c2673a8..52eba219 100644 --- a/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigProperties.java +++ b/spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigProperties.java @@ -116,8 +116,8 @@ public class ConfigMapConfigProperties extends AbstractConfigProperties { private Boolean useNameAsPrefix; /** - * Use profile name to append to a config map name. Can't be a primitive, we need to - * know if it was explicitly set or not + * Use profile name to append to a config map name. Can't be a primitive, we need + * to know if it was explicitly set or not */ protected Boolean includeProfileSpecificSources; @@ -193,8 +193,8 @@ public class ConfigMapConfigProperties extends AbstractConfigProperties { String normalizedNamespace = StringUtils.hasLength(this.namespace) ? this.namespace : defaultNamespace; String prefix = ConfigUtils.findPrefix(this.explicitPrefix, useNameAsPrefix, defaultUseNameAsPrefix, normalizedName); - boolean includeProfileSpecificSources = ConfigUtils.includeProfileSpecificSources(defaultIncludeProfileSpecificSources, - this.includeProfileSpecificSources); + boolean includeProfileSpecificSources = ConfigUtils.includeProfileSpecificSources( + defaultIncludeProfileSpecificSources, this.includeProfileSpecificSources); return new NormalizedSource(normalizedName, normalizedNamespace, prefix, includeProfileSpecificSources); } 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 a0e4126d..0d507076 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 @@ -92,7 +92,7 @@ public final class ConfigUtils { * @return useProfileNameAsPrefix to be used in normalized sources */ public static boolean includeProfileSpecificSources(boolean defaultIncludeProfileSpecificSources, - Boolean includeProfileSpecificSources) { + Boolean includeProfileSpecificSources) { if (includeProfileSpecificSources != null) { return includeProfileSpecificSources; } diff --git a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesTests.java b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesTests.java index 4fe06132..d665fbb4 100644 --- a/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesTests.java +++ b/spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigPropertiesTests.java @@ -228,9 +228,9 @@ public class ConfigMapConfigPropertiesTests { * namespace: spring-k8s * * - * a config as above will result in a NormalizedSource where includeProfileSpecificSources - * will be true (this test proves that the change we added is not a breaking change - * for the already existing functionality) + * a config as above will result in a NormalizedSource where + * includeProfileSpecificSources will be true (this test proves that the change we + * added is not a breaking change for the already existing functionality) */ @Test public void testUseIncludeProfileSpecificSourcesNoChanges() { @@ -256,11 +256,11 @@ public class ConfigMapConfigPropertiesTests { * namespace: spring-k8s * * - * a config as above will result in a NormalizedSource where includeProfileSpecificSources - * will be false. Even if we did not define any sources explicitly, one will still be - * created, by default. That one might "flatMap" into multiple other, because of - * multiple profiles. As such this setting still matters and must be propagated to the - * normalized source. + * a config as above will result in a NormalizedSource where + * includeProfileSpecificSources will be false. Even if we did not define any sources + * explicitly, one will still be created, by default. That one might "flatMap" into + * multiple other, because of multiple profiles. As such this setting still matters + * and must be propagated to the normalized source. */ @Test public void testUseIncludeProfileSpecificSourcesDefaultChanged() { diff --git a/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/main/java/org/springframework/cloud/kubernetes/configserver/KubernetesConfigServerAutoConfiguration.java b/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/main/java/org/springframework/cloud/kubernetes/configserver/KubernetesConfigServerAutoConfiguration.java index 38f27ab7..3fc7af42 100644 --- a/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/main/java/org/springframework/cloud/kubernetes/configserver/KubernetesConfigServerAutoConfiguration.java +++ b/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/main/java/org/springframework/cloud/kubernetes/configserver/KubernetesConfigServerAutoConfiguration.java @@ -69,8 +69,8 @@ public class KubernetesConfigServerAutoConfiguration { return (coreApi, applicationName, namespace, springEnv) -> { List namespaces = namespaceSplitter(properties.getSecretsNamespaces(), namespace); List propertySources = new ArrayList<>(); - namespaces.forEach(space -> propertySources - .add(new KubernetesClientConfigMapPropertySource(coreApi, applicationName, space, springEnv, ""))); + namespaces.forEach(space -> propertySources.add( + new KubernetesClientConfigMapPropertySource(coreApi, applicationName, space, springEnv, "", true))); return propertySources; }; } diff --git a/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/test/java/org/springframework/cloud/kubernetes/configserver/KubernetesEnvironmentRepositoryTests.java b/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/test/java/org/springframework/cloud/kubernetes/configserver/KubernetesEnvironmentRepositoryTests.java index 59b0bdf5..206c340b 100644 --- a/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/test/java/org/springframework/cloud/kubernetes/configserver/KubernetesEnvironmentRepositoryTests.java +++ b/spring-cloud-kubernetes-controllers/spring-cloud-kubernetes-configserver/src/test/java/org/springframework/cloud/kubernetes/configserver/KubernetesEnvironmentRepositoryTests.java @@ -96,10 +96,10 @@ class KubernetesEnvironmentRepositoryTests { public static void before() { kubernetesPropertySourceSuppliers.add((coreApi, applicationName, namespace, springEnv) -> { List propertySources = new ArrayList<>(); + propertySources.add(new KubernetesClientConfigMapPropertySource(coreApi, applicationName, "default", + springEnv, "", true)); propertySources.add( - new KubernetesClientConfigMapPropertySource(coreApi, applicationName, "default", springEnv, "")); - propertySources - .add(new KubernetesClientConfigMapPropertySource(coreApi, applicationName, "dev", springEnv, "")); + new KubernetesClientConfigMapPropertySource(coreApi, applicationName, "dev", springEnv, "", true)); return propertySources; }); kubernetesPropertySourceSuppliers.add((coreApi, applicationName, namespace, springEnv) -> { diff --git a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapWithIncludeProfileSpecificSourcesTests.java b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapWithIncludeProfileSpecificSourcesTests.java index 7d1a7021..a6b87fce 100644 --- a/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapWithIncludeProfileSpecificSourcesTests.java +++ b/spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/ConfigMapWithIncludeProfileSpecificSourcesTests.java @@ -19,6 +19,7 @@ package org.springframework.cloud.kubernetes.fabric8.config; import java.util.HashMap; import java.util.Map; +import io.fabric8.kubernetes.api.model.ConfigMapBuilder; import io.fabric8.kubernetes.client.Config; import io.fabric8.kubernetes.client.KubernetesClient; import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient; @@ -39,7 +40,8 @@ import org.springframework.test.web.reactive.server.WebTestClient; * @author wind57 */ @ExtendWith(SpringExtension.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = IncludeProfileSpecificSourcesApp.class, +@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, + classes = IncludeProfileSpecificSourcesApp.class, properties = { "spring.cloud.bootstrap.name=include-profile-specific-sources" }) @AutoConfigureWebTestClient @EnableKubernetesMockClient(crud = true, https = false) @@ -85,8 +87,8 @@ class ConfigMapWithIncludeProfileSpecificSourcesTests { } private static void createConfigmap(String name, Map data) { - mockClient.configMaps().inNamespace("spring-k8s").createNew().withNewMetadata().withName(name).endMetadata() - .addToData(data).done(); + mockClient.configMaps().inNamespace("spring-k8s") + .create(new ConfigMapBuilder().withNewMetadata().withName(name).endMetadata().addToData(data).build()); } /**