Resolve merge conflicts from 2.0.x branch

This commit is contained in:
Ryan Baxter
2021-10-21 17:08:01 -04:00
parent 7fa25cf883
commit d6e7e5924e
8 changed files with 28 additions and 23 deletions

View File

@@ -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 {

View File

@@ -76,4 +76,5 @@ public abstract class AbstractConfigProperties {
public void setIncludeProfileSpecificSources(boolean includeProfileSpecificSources) {
this.includeProfileSpecificSources = includeProfileSpecificSources;
}
}

View File

@@ -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);
}

View File

@@ -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;
}

View File

@@ -228,9 +228,9 @@ public class ConfigMapConfigPropertiesTests {
* namespace: spring-k8s
* </pre>
*
* 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
* </pre>
*
* 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() {

View File

@@ -69,8 +69,8 @@ public class KubernetesConfigServerAutoConfiguration {
return (coreApi, applicationName, namespace, springEnv) -> {
List<String> namespaces = namespaceSplitter(properties.getSecretsNamespaces(), namespace);
List<MapPropertySource> 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;
};
}

View File

@@ -96,10 +96,10 @@ class KubernetesEnvironmentRepositoryTests {
public static void before() {
kubernetesPropertySourceSuppliers.add((coreApi, applicationName, namespace, springEnv) -> {
List<MapPropertySource> 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) -> {

View File

@@ -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<String, String> 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());
}
/**