@@ -37,6 +37,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
|
||||
import org.springframework.cloud.kubernetes.commons.config.ConfigMapConfigProperties;
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.commons.config.NamespaceResolutionFailedException;
|
||||
import org.springframework.cloud.kubernetes.commons.config.RetryProperties;
|
||||
import org.springframework.core.env.PropertySource;
|
||||
@@ -62,7 +63,7 @@ class KubernetesClientConfigMapPropertySourceLocatorTests {
|
||||
.withNamespace("default")
|
||||
.withResourceVersion("1")
|
||||
.build())
|
||||
.addToData("application.properties",
|
||||
.addToData(Constants.APPLICATION_PROPERTIES,
|
||||
"spring.cloud.kubernetes.configuration.watcher.refreshDelay=0\n"
|
||||
+ "logging.level.org.springframework.cloud.kubernetes=TRACE")
|
||||
.build());
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.config.ConfigUtils;
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.commons.config.NamedConfigMapNormalizedSource;
|
||||
import org.springframework.cloud.kubernetes.commons.config.NormalizedSource;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
@@ -59,7 +60,7 @@ class KubernetesClientConfigMapPropertySourceTests {
|
||||
.withNamespace("default")
|
||||
.withResourceVersion("1")
|
||||
.build())
|
||||
.addToData("application.properties",
|
||||
.addToData(Constants.APPLICATION_PROPERTIES,
|
||||
"spring.cloud.kubernetes.configuration.watcher.refreshDelay=0\n"
|
||||
+ "logging.level.org.springframework.cloud.kubernetes=TRACE")
|
||||
.build());
|
||||
@@ -70,7 +71,7 @@ class KubernetesClientConfigMapPropertySourceTests {
|
||||
.withNamespace("default")
|
||||
.withResourceVersion("1")
|
||||
.build())
|
||||
.addToData("application.yaml", "dummy:\n property:\n string2: \"a\"\n int2: 1\n bool2: true\n")
|
||||
.addToData(Constants.APPLICATION_YAML, "dummy:\n property:\n string2: \"a\"\n int2: 1\n bool2: true\n")
|
||||
.build());
|
||||
|
||||
private static WireMockServer wireMockServer;
|
||||
|
||||
@@ -51,6 +51,7 @@ import org.junit.jupiter.api.Test;
|
||||
import org.springframework.cloud.kubernetes.client.config.KubernetesClientConfigMapPropertySource;
|
||||
import org.springframework.cloud.kubernetes.client.config.KubernetesClientConfigMapPropertySourceLocator;
|
||||
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadProperties;
|
||||
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigurationUpdateStrategy;
|
||||
import org.springframework.mock.env.MockPropertySource;
|
||||
@@ -99,10 +100,10 @@ class KubernetesClientEventBasedConfigMapChangeDetectorTests {
|
||||
Gson gson = builder.create();
|
||||
|
||||
Map<String, String> data = new HashMap<>();
|
||||
data.put("application.properties", "spring.cloud.kubernetes.configuration.watcher.refreshDelay=0\n"
|
||||
data.put(Constants.APPLICATION_PROPERTIES, "spring.cloud.kubernetes.configuration.watcher.refreshDelay=0\n"
|
||||
+ "logging.level.org.springframework.cloud.kubernetes=TRACE");
|
||||
Map<String, String> updateData = new HashMap<>();
|
||||
updateData.put("application.properties", "spring.cloud.kubernetes.configuration.watcher.refreshDelay=1\n"
|
||||
updateData.put(Constants.APPLICATION_PROPERTIES, "spring.cloud.kubernetes.configuration.watcher.refreshDelay=1\n"
|
||||
+ "logging.level.org.springframework.cloud.kubernetes=TRACE");
|
||||
V1ConfigMap applicationConfig = new V1ConfigMap().kind("ConfigMap")
|
||||
.metadata(new V1ObjectMeta().namespace("default").name("bar1"))
|
||||
@@ -132,7 +133,7 @@ class KubernetesClientEventBasedConfigMapChangeDetectorTests {
|
||||
.withBody(new JSON().serialize(new Watch.Response<>(EventType.ADDED.name(),
|
||||
new V1ConfigMap().kind("ConfigMap")
|
||||
.metadata(new V1ObjectMeta().namespace("default").name("bar3"))
|
||||
.putDataItem("application.properties", "debug=true")))))
|
||||
.putDataItem(Constants.APPLICATION_PROPERTIES, "debug=true")))))
|
||||
.willSetStateTo("delete"));
|
||||
|
||||
stubFor(get(urlMatching("^/api/v1/namespaces/default/configmaps.*")).inScenario("watch")
|
||||
@@ -142,7 +143,7 @@ class KubernetesClientEventBasedConfigMapChangeDetectorTests {
|
||||
.withBody(new JSON().serialize(new Watch.Response<>(EventType.DELETED.name(),
|
||||
new V1ConfigMap().kind("ConfigMap")
|
||||
.metadata(new V1ObjectMeta().namespace("default").name("bar1"))
|
||||
.putDataItem("application.properties", "debug=true")))))
|
||||
.putDataItem(Constants.APPLICATION_PROPERTIES, "debug=true")))))
|
||||
.willSetStateTo("done"));
|
||||
|
||||
stubFor(get(urlMatching("^/api/v1/namespaces/default/configmaps.*")).inScenario("watch")
|
||||
|
||||
@@ -179,10 +179,10 @@ class ConfigUtilsTests {
|
||||
void testMerge() {
|
||||
|
||||
StrippedSourceContainer configMapOne = new StrippedSourceContainer(Map.of(), "configmap-one",
|
||||
Map.of("application.yaml", "propA: A\npropB: B"));
|
||||
Map.of(Constants.APPLICATION_YAML, "propA: A\npropB: B"));
|
||||
|
||||
StrippedSourceContainer configMapOneK8s = new StrippedSourceContainer(Map.of(), "configmap-one-kubernetes",
|
||||
Map.of("application.yaml", "propA: AA\npropC: C"));
|
||||
Map.of(Constants.APPLICATION_YAML, "propA: AA\npropC: C"));
|
||||
|
||||
LinkedHashSet<String> sourceNames = Stream.of("configmap-one", "configmap-one-kubernetes")
|
||||
.collect(Collectors.toCollection(LinkedHashSet::new));
|
||||
|
||||
@@ -53,7 +53,7 @@ class SourceDataEntriesProcessorOrderedPropertiesTests {
|
||||
@Test
|
||||
void testSingleFileProperty() {
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("application.properties", "my-key=from-app");
|
||||
map.put(Constants.APPLICATION_PROPERTIES, "my-key=from-app");
|
||||
|
||||
MockEnvironment mockEnvironment = new MockEnvironment();
|
||||
Map<String, Object> result = SourceDataEntriesProcessor.processAllEntries(map, mockEnvironment);
|
||||
@@ -78,7 +78,7 @@ class SourceDataEntriesProcessorOrderedPropertiesTests {
|
||||
void testThree() {
|
||||
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("application.properties", """
|
||||
map.put(Constants.APPLICATION_PROPERTIES, """
|
||||
firstKey=firstFromProperties
|
||||
secondKey=secondFromProperties""");
|
||||
map.put("firstKey", "abc");
|
||||
@@ -114,7 +114,7 @@ class SourceDataEntriesProcessorOrderedPropertiesTests {
|
||||
void testFour() {
|
||||
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("application.properties", """
|
||||
map.put(Constants.APPLICATION_PROPERTIES, """
|
||||
firstKey=firstFromProperties
|
||||
secondKey=secondFromProperties
|
||||
thirdKey=thirdFromProperties""");
|
||||
@@ -158,7 +158,7 @@ class SourceDataEntriesProcessorOrderedPropertiesTests {
|
||||
void testFive() {
|
||||
|
||||
Map<String, String> map = new LinkedHashMap<>();
|
||||
map.put("application.properties", """
|
||||
map.put(Constants.APPLICATION_PROPERTIES, """
|
||||
firstKey=firstFromProperties
|
||||
secondKey=secondFromProperties
|
||||
thirdKey=thirdFromProperties""");
|
||||
|
||||
@@ -66,13 +66,13 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
void testSingleFileProperty() {
|
||||
|
||||
Map<String, String> k8sSource = new LinkedHashMap<>();
|
||||
k8sSource.put("application.properties", "key=value");
|
||||
k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value");
|
||||
|
||||
MockEnvironment mockEnvironment = new MockEnvironment();
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 1);
|
||||
Assertions.assertEquals(result.get(0).getKey(), "application.properties");
|
||||
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertEquals(result.get(0).getValue(), "key=value");
|
||||
}
|
||||
|
||||
@@ -80,14 +80,14 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
void testApplicationAndSimpleProperty() {
|
||||
|
||||
Map<String, String> k8sSource = new LinkedHashMap<>();
|
||||
k8sSource.put("application.properties", "key=value");
|
||||
k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value");
|
||||
k8sSource.put("simple", "other_value");
|
||||
|
||||
MockEnvironment mockEnvironment = new MockEnvironment();
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 2);
|
||||
Assertions.assertEquals(result.get(0).getKey(), "application.properties");
|
||||
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertEquals(result.get(0).getValue(), "key=value");
|
||||
|
||||
Assertions.assertEquals(result.get(1).getKey(), "simple");
|
||||
@@ -99,13 +99,13 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
|
||||
Map<String, String> k8sSource = new LinkedHashMap<>();
|
||||
k8sSource.put("simple", "other_value");
|
||||
k8sSource.put("application.properties", "key=value");
|
||||
k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value");
|
||||
|
||||
MockEnvironment mockEnvironment = new MockEnvironment();
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 2);
|
||||
Assertions.assertEquals(result.get(0).getKey(), "application.properties");
|
||||
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertEquals(result.get(0).getValue(), "key=value");
|
||||
|
||||
Assertions.assertEquals(result.get(1).getKey(), "simple");
|
||||
@@ -117,7 +117,7 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
|
||||
Map<String, String> k8sSource = new LinkedHashMap<>();
|
||||
k8sSource.put("simple", "other_value");
|
||||
k8sSource.put("application.properties", "key=value");
|
||||
k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value");
|
||||
k8sSource.put("application-dev.properties", "key-dev=value-dev");
|
||||
|
||||
MockEnvironment mockEnvironment = new MockEnvironment();
|
||||
@@ -125,7 +125,7 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 3);
|
||||
Assertions.assertEquals(result.get(0).getKey(), "application.properties");
|
||||
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertEquals(result.get(0).getValue(), "key=value");
|
||||
|
||||
Assertions.assertEquals(result.get(1).getKey(), "application-dev.properties");
|
||||
@@ -140,7 +140,7 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
|
||||
Map<String, String> k8sSource = new LinkedHashMap<>();
|
||||
k8sSource.put("simple", "other_value");
|
||||
k8sSource.put("application.properties", "key=value");
|
||||
k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value");
|
||||
k8sSource.put("application-dev.properties", "key-dev=value-dev");
|
||||
|
||||
MockEnvironment mockEnvironment = new MockEnvironment();
|
||||
@@ -159,7 +159,7 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
Map<String, String> k8sSource = new LinkedHashMap<>();
|
||||
k8sSource.put("simple", "other_value");
|
||||
k8sSource.put("second-simple", "second_other_value");
|
||||
k8sSource.put("application.properties", "key=value");
|
||||
k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value");
|
||||
k8sSource.put("application-dev.properties", "key-dev=value-dev");
|
||||
k8sSource.put("application-k8s.properties", "key-k8s=value-k8s");
|
||||
k8sSource.put("ignored.properties", "key-ignored=value-ignored");
|
||||
@@ -169,7 +169,7 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
|
||||
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
|
||||
Assertions.assertEquals(result.size(), 4);
|
||||
Assertions.assertEquals(result.get(0).getKey(), "application.properties");
|
||||
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
|
||||
Assertions.assertEquals(result.get(0).getValue(), "key=value");
|
||||
|
||||
Assertions.assertEquals(result.get(1).getKey(), "application-k8s.properties");
|
||||
@@ -188,7 +188,7 @@ class SourceDataEntriesProcessorSortedTests {
|
||||
Map<String, String> k8sSource = new LinkedHashMap<>();
|
||||
k8sSource.put("simple", "other_value");
|
||||
k8sSource.put("second-simple", "second_other_value");
|
||||
k8sSource.put("application.properties", "key=value");
|
||||
k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value");
|
||||
k8sSource.put("application-dev.properties", "key-dev=value-dev");
|
||||
k8sSource.put("application-k8s.properties", "key-k8s=value-k8s");
|
||||
k8sSource.put("ignored.properties", "key-ignored=value-ignored");
|
||||
|
||||
@@ -106,7 +106,7 @@ class SourceDataEntriesProcessorTests {
|
||||
void twoEntriesBothTaken() {
|
||||
|
||||
Map.Entry<String, String> one = Map.entry("one", "1");
|
||||
Map.Entry<String, String> application = Map.entry("application.yaml", "color: \n blue");
|
||||
Map.Entry<String, String> application = Map.entry(Constants.APPLICATION_YAML, "color: \n blue");
|
||||
Map<String, String> map = Map.ofEntries(one, application);
|
||||
|
||||
Map<String, Object> result = SourceDataEntriesProcessor.processAllEntries(map, new MockEnvironment());
|
||||
@@ -127,7 +127,7 @@ class SourceDataEntriesProcessorTests {
|
||||
void threeEntriesAllTaken() {
|
||||
|
||||
Map.Entry<String, String> one = Map.entry("one", "1");
|
||||
Map.Entry<String, String> application = Map.entry("application.properties", "color=blue");
|
||||
Map.Entry<String, String> application = Map.entry(Constants.APPLICATION_PROPERTIES, "color=blue");
|
||||
Map.Entry<String, String> applicationDev = Map.entry("application-dev.properties", "fit=sport");
|
||||
Map<String, String> map = Map.ofEntries(one, application, applicationDev);
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@ import org.springframework.cloud.kubernetes.client.config.KubernetesClientConfig
|
||||
import org.springframework.cloud.kubernetes.client.config.KubernetesClientConfigMapsCache;
|
||||
import org.springframework.cloud.kubernetes.client.config.KubernetesClientSecretsPropertySource;
|
||||
import org.springframework.cloud.kubernetes.commons.config.ConfigUtils;
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.commons.config.NamedConfigMapNormalizedSource;
|
||||
import org.springframework.cloud.kubernetes.commons.config.NamedSecretNormalizedSource;
|
||||
import org.springframework.cloud.kubernetes.commons.config.NormalizedSource;
|
||||
@@ -74,15 +75,15 @@ class KubernetesEnvironmentRepositoryTests {
|
||||
private static final V1ConfigMapList CONFIGMAP_DEFAULT_LIST = new V1ConfigMapList()
|
||||
.addItemsItem(new V1ConfigMapBuilder()
|
||||
.withMetadata(new V1ObjectMetaBuilder().withName("application").withNamespace(DEFAULT_NAMESPACE).build())
|
||||
.addToData("application.yaml", VALUE)
|
||||
.addToData(Constants.APPLICATION_YAML, VALUE)
|
||||
.build())
|
||||
.addItemsItem(new V1ConfigMapBuilder()
|
||||
.withMetadata(new V1ObjectMetaBuilder().withName("stores").withNamespace(DEFAULT_NAMESPACE).build())
|
||||
.addToData("application.yaml", VALUE)
|
||||
.addToData(Constants.APPLICATION_YAML, VALUE)
|
||||
.build())
|
||||
.addItemsItem(new V1ConfigMapBuilder()
|
||||
.withMetadata(new V1ObjectMetaBuilder().withName("stores-dev").withNamespace(DEFAULT_NAMESPACE).build())
|
||||
.addToData("application.yaml",
|
||||
.addToData(Constants.APPLICATION_YAML,
|
||||
"dummy:\n property:\n string1: \"a\"\n string2: \"b\"\n int2: 2\n bool2: false\n")
|
||||
.build());
|
||||
|
||||
@@ -90,7 +91,7 @@ class KubernetesEnvironmentRepositoryTests {
|
||||
.addItemsItem(new V1ConfigMapBuilder()
|
||||
.withMetadata(
|
||||
new V1ObjectMetaBuilder().withName("stores").withNamespace("dev").withResourceVersion("1").build())
|
||||
.addToData("application.yaml", "dummy:\n property:\n string2: \"dev\"\n int2: 1\n bool2: true\n")
|
||||
.addToData(Constants.APPLICATION_YAML, "dummy:\n property:\n string2: \"dev\"\n int2: 1\n bool2: true\n")
|
||||
.build());
|
||||
|
||||
private static final V1SecretList SECRET_LIST = new V1SecretListBuilder()
|
||||
|
||||
@@ -32,6 +32,7 @@ import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.cloud.config.environment.Environment;
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -180,7 +181,7 @@ class KubernetesPropertySourceSupplierTests {
|
||||
return new V1ConfigMapBuilder()
|
||||
.withMetadata(
|
||||
new V1ObjectMetaBuilder().withName(name).withNamespace(namespace).withResourceVersion("1").build())
|
||||
.addToData("application.yaml", "dummy:\n property:\n string: \"" + name + "\"\n")
|
||||
.addToData(Constants.APPLICATION_YAML, "dummy:\n property:\n string: \"" + name + "\"\n")
|
||||
.build();
|
||||
}
|
||||
|
||||
|
||||
@@ -31,6 +31,8 @@ import org.springframework.cloud.kubernetes.commons.config.NormalizedSource;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.springframework.cloud.kubernetes.commons.config.Constants.APPLICATION_PROPERTIES;
|
||||
import static org.springframework.cloud.kubernetes.commons.config.Constants.APPLICATION_YAML;
|
||||
|
||||
/**
|
||||
* @author Charles Moulliard
|
||||
@@ -84,7 +86,7 @@ class ConfigMapsTest {
|
||||
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata()
|
||||
.withName(configMapName)
|
||||
.endMetadata()
|
||||
.addToData("application.properties", ConfigMapTestUtil.readResourceFile("application.properties"))
|
||||
.addToData(APPLICATION_PROPERTIES, ConfigMapTestUtil.readResourceFile(APPLICATION_PROPERTIES))
|
||||
.build();
|
||||
|
||||
mockClient.configMaps().inNamespace("test").resource(configMap).create();
|
||||
@@ -104,7 +106,7 @@ class ConfigMapsTest {
|
||||
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata()
|
||||
.withName(configMapName)
|
||||
.endMetadata()
|
||||
.addToData("application.yaml", ConfigMapTestUtil.readResourceFile("application.yaml"))
|
||||
.addToData(APPLICATION_YAML, ConfigMapTestUtil.readResourceFile(APPLICATION_YAML))
|
||||
.build();
|
||||
|
||||
mockClient.configMaps().inNamespace("test").resource(configMap).create();
|
||||
@@ -144,7 +146,7 @@ class ConfigMapsTest {
|
||||
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata()
|
||||
.withName(configMapName)
|
||||
.endMetadata()
|
||||
.addToData("application.properties", "somevalue")
|
||||
.addToData(APPLICATION_PROPERTIES, "somevalue")
|
||||
.build();
|
||||
|
||||
mockClient.configMaps().inNamespace("test").resource(configMap).create();
|
||||
@@ -162,7 +164,7 @@ class ConfigMapsTest {
|
||||
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata()
|
||||
.withName(configMapName)
|
||||
.endMetadata()
|
||||
.addToData("application.yaml", "somevalue")
|
||||
.addToData(APPLICATION_YAML, "somevalue")
|
||||
.build();
|
||||
|
||||
mockClient.configMaps().inNamespace("test").resource(configMap).create();
|
||||
@@ -180,7 +182,7 @@ class ConfigMapsTest {
|
||||
ConfigMap configMap = new ConfigMapBuilder().withNewMetadata()
|
||||
.withName(configMapName)
|
||||
.endMetadata()
|
||||
.addToData("application.properties", ConfigMapTestUtil.readResourceFile("application.properties"))
|
||||
.addToData(APPLICATION_PROPERTIES, ConfigMapTestUtil.readResourceFile(APPLICATION_PROPERTIES))
|
||||
.addToData("adhoc.properties", ConfigMapTestUtil.readResourceFile("adhoc.properties"))
|
||||
.build();
|
||||
|
||||
|
||||
@@ -36,6 +36,8 @@ import org.springframework.cloud.kubernetes.commons.config.MultipleSourcesContai
|
||||
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadProperties;
|
||||
import org.springframework.mock.env.MockEnvironment;
|
||||
|
||||
import static org.springframework.cloud.kubernetes.commons.config.Constants.APPLICATION_YAML;
|
||||
|
||||
/**
|
||||
* @author wind57
|
||||
*/
|
||||
@@ -91,7 +93,7 @@ class Fabric8ConfigUtilsTests {
|
||||
.inNamespace("spring-k8s")
|
||||
.resource(new SecretBuilder()
|
||||
.withMetadata(new ObjectMetaBuilder().withName("my-secret").withLabels(Map.of("color", "pink")).build())
|
||||
.addToData(Map.of("application.yaml", Base64.getEncoder().encodeToString("key1: value1".getBytes())))
|
||||
.addToData(Map.of(APPLICATION_YAML, Base64.getEncoder().encodeToString("key1: value1".getBytes())))
|
||||
.build())
|
||||
.create();
|
||||
|
||||
@@ -324,7 +326,7 @@ class Fabric8ConfigUtilsTests {
|
||||
client.configMaps()
|
||||
.inNamespace("spring-k8s")
|
||||
.resource(new ConfigMapBuilder().withMetadata(new ObjectMetaBuilder().withName("my-config-map").build())
|
||||
.addToData(Map.of("application.yaml", "key1: value1"))
|
||||
.addToData(Map.of(APPLICATION_YAML, "key1: value1"))
|
||||
.build())
|
||||
.create();
|
||||
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.fabric8.config.TestApplication;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
|
||||
@@ -54,7 +55,7 @@ abstract class ConfigMapsWithProfilesNoActiveProfile {
|
||||
System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true");
|
||||
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
data.put("application.yml", readResourceFile("application-with-profiles.yaml"));
|
||||
data.put(Constants.APPLICATION_YML, readResourceFile("application-with-profiles.yaml"));
|
||||
mockClient.configMaps()
|
||||
.inNamespace("test")
|
||||
.resource(new ConfigMapBuilder().withNewMetadata()
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.fabric8.config.ConfigMapTestUtil;
|
||||
import org.springframework.cloud.kubernetes.fabric8.config.TestApplication;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
@@ -55,7 +56,7 @@ abstract class ConfigMapsWithProfileExpression {
|
||||
System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true");
|
||||
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
data.put("application.yml", ConfigMapTestUtil.readResourceFile("application-with-profiles.yaml"));
|
||||
data.put(Constants.APPLICATION_YML, ConfigMapTestUtil.readResourceFile("application-with-profiles.yaml"));
|
||||
mockClient.configMaps()
|
||||
.inNamespace("test")
|
||||
.resource(new ConfigMapBuilder().withNewMetadata()
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.fabric8.config.ConfigMapTestUtil;
|
||||
import org.springframework.cloud.kubernetes.fabric8.config.TestApplication;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
@@ -58,7 +59,7 @@ abstract class ConfigMapsWithProfiles {
|
||||
System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true");
|
||||
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
data.put("application.yml", ConfigMapTestUtil.readResourceFile("application-with-profiles.yaml"));
|
||||
data.put(Constants.APPLICATION_YML, ConfigMapTestUtil.readResourceFile("application-with-profiles.yaml"));
|
||||
mockClient.configMaps()
|
||||
.inNamespace("test")
|
||||
.resource(new ConfigMapBuilder().withNewMetadata()
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.fabric8.config.TestApplication;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
@@ -59,7 +60,7 @@ abstract class ConfigMapsWithActiveProfilesName {
|
||||
System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true");
|
||||
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
data.put("application.yml", readResourceFile("application-with-profiles.yaml"));
|
||||
data.put(Constants.APPLICATION_YML, readResourceFile("application-with-profiles.yaml"));
|
||||
mockClient.configMaps()
|
||||
.inNamespace("test")
|
||||
.resource(new ConfigMapBuilder().withNewMetadata()
|
||||
@@ -70,7 +71,7 @@ abstract class ConfigMapsWithActiveProfilesName {
|
||||
.create();
|
||||
|
||||
HashMap<String, String> dataWithName = new HashMap<>();
|
||||
dataWithName.put("application.yml", readResourceFile("application-with-active-profiles-name.yaml"));
|
||||
dataWithName.put(Constants.APPLICATION_YML, readResourceFile("application-with-active-profiles-name.yaml"));
|
||||
mockClient.configMaps()
|
||||
.inNamespace("test")
|
||||
.resource(new ConfigMapBuilder().withNewMetadata()
|
||||
|
||||
@@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.fabric8.config.ConfigMapTestUtil;
|
||||
import org.springframework.cloud.kubernetes.fabric8.config.TestApplication;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
@@ -52,7 +53,7 @@ abstract class ConfigMapsWithoutProfiles {
|
||||
System.setProperty(Config.KUBERNETES_HTTP2_DISABLE, "true");
|
||||
|
||||
HashMap<String, String> data = new HashMap<>();
|
||||
data.put("application.yml", ConfigMapTestUtil.readResourceFile("application-without-profiles.yaml"));
|
||||
data.put(Constants.APPLICATION_YML, ConfigMapTestUtil.readResourceFile("application-without-profiles.yaml"));
|
||||
mockClient.configMaps()
|
||||
.inNamespace("test")
|
||||
.resource(new ConfigMapBuilder().withNewMetadata()
|
||||
|
||||
@@ -28,6 +28,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.fabric8.config.ConfigMapTestUtil;
|
||||
import org.springframework.cloud.kubernetes.fabric8.config.TestApplication;
|
||||
import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
@@ -45,20 +46,18 @@ abstract class ConfigMapsFromFilePaths {
|
||||
|
||||
protected static final String FILES_SUB_PATH = "another-directory";
|
||||
|
||||
protected static final String FIRST_FILE_NAME = "application.properties";
|
||||
|
||||
protected static final String SECOND_FILE_NAME = "extra.properties";
|
||||
|
||||
protected static final String UNUSED_FILE_NAME = "unused.properties";
|
||||
|
||||
protected static final String FIRST_FILE_NAME_FULL_PATH = FILES_ROOT_PATH + "/" + FIRST_FILE_NAME;
|
||||
protected static final String FIRST_FILE_NAME_FULL_PATH = FILES_ROOT_PATH + "/" + Constants.APPLICATION_PROPERTIES;
|
||||
|
||||
protected static final String SECOND_FILE_NAME_FULL_PATH = FILES_ROOT_PATH + "/" + SECOND_FILE_NAME;
|
||||
|
||||
protected static final String UNUSED_FILE_NAME_FULL_PATH = FILES_ROOT_PATH + "/" + UNUSED_FILE_NAME;
|
||||
|
||||
protected static final String FIRST_FILE_NAME_DUPLICATED_FULL_PATH = FILES_ROOT_PATH + "/" + FILES_SUB_PATH + "/"
|
||||
+ FIRST_FILE_NAME;
|
||||
+ Constants.APPLICATION_PROPERTIES;
|
||||
|
||||
@Autowired
|
||||
private WebTestClient webClient;
|
||||
|
||||
@@ -26,6 +26,7 @@ import io.fabric8.kubernetes.client.utils.Serialization;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.fabric8_client.Util;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -71,7 +72,7 @@ final class BootstrapEnabledPollingReloadConfigMapMountDelegate {
|
||||
// our polling will detect that and restart the app
|
||||
InputStream configMapStream = util.inputStream("configmap.yaml");
|
||||
ConfigMap configMap = Serialization.unmarshal(configMapStream, ConfigMap.class);
|
||||
configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed"));
|
||||
configMap.setData(Map.of(Constants.APPLICATION_PROPERTIES, "from.properties.key=as-mount-changed"));
|
||||
client.configMaps().inNamespace("default").resource(configMap).createOrReplace();
|
||||
|
||||
await().timeout(Duration.ofSeconds(360))
|
||||
|
||||
@@ -26,6 +26,7 @@ import io.fabric8.kubernetes.client.utils.Serialization;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.fabric8_client.Util;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -75,7 +76,7 @@ final class ConfigMapMountPollingReloadDelegate {
|
||||
// our polling will detect that and restart the app
|
||||
InputStream configMapStream = util.inputStream("configmap.yaml");
|
||||
ConfigMap configMap = Serialization.unmarshal(configMapStream, ConfigMap.class);
|
||||
configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed"));
|
||||
configMap.setData(Map.of(Constants.APPLICATION_PROPERTIES, "from.properties.key=as-mount-changed"));
|
||||
client.configMaps().inNamespace("default").resource(configMap).createOrReplace();
|
||||
|
||||
await().timeout(Duration.ofSeconds(360))
|
||||
|
||||
@@ -27,6 +27,7 @@ import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
@@ -68,7 +69,7 @@ final class SecretsEventsReloadDelegate {
|
||||
.withNamespace("default")
|
||||
.withName("event-reload")
|
||||
.build())
|
||||
.withData(Map.of("application.properties",
|
||||
.withData(Map.of(Constants.APPLICATION_PROPERTIES,
|
||||
Base64.getEncoder().encodeToString("from.secret.properties.key=secret-initial".getBytes())))
|
||||
.build();
|
||||
client.secrets().inNamespace("default").resource(secret).createOrReplace();
|
||||
@@ -89,7 +90,7 @@ final class SecretsEventsReloadDelegate {
|
||||
// change data
|
||||
secret = new SecretBuilder()
|
||||
.withMetadata(new ObjectMetaBuilder().withNamespace("default").withName("event-reload").build())
|
||||
.withData(Map.of("application.properties",
|
||||
.withData(Map.of(Constants.APPLICATION_PROPERTIES,
|
||||
Base64.getEncoder().encodeToString("from.secret.properties.key=secret-initial-changed".getBytes())))
|
||||
.build();
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.kubernetes.client.openapi.models.V1ConfigMap;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -80,7 +81,7 @@ final class BootstrapEnabledPollingReloadConfigMapMountDelegate {
|
||||
// replace data in configmap and wait for k8s to pick it up
|
||||
// our polling will detect that and restart the app
|
||||
V1ConfigMap configMap = (V1ConfigMap) util.yaml("configmap-mount.yaml");
|
||||
configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed"));
|
||||
configMap.setData(Map.of(Constants.APPLICATION_PROPERTIES, "from.properties.key=as-mount-changed"));
|
||||
new CoreV1Api().replaceNamespacedConfigMap("poll-reload-as-mount", NAMESPACE, configMap, null, null, null,
|
||||
null);
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import io.kubernetes.client.openapi.models.V1ConfigMap;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util;
|
||||
import org.springframework.http.HttpMethod;
|
||||
@@ -82,7 +83,7 @@ final class PollingReloadConfigMapMountDelegate {
|
||||
// replace data in configmap and wait for k8s to pick it up
|
||||
// our polling will detect that and restart the app
|
||||
V1ConfigMap configMap = (V1ConfigMap) util.yaml("configmap-mount.yaml");
|
||||
configMap.setData(Map.of("application.properties", "from.properties.key=as-mount-changed"));
|
||||
configMap.setData(Map.of(Constants.APPLICATION_PROPERTIES, "from.properties.key=as-mount-changed"));
|
||||
new CoreV1Api().replaceNamespacedConfigMap("poll-reload-as-mount", "default", configMap, null, null, null,
|
||||
null);
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import io.kubernetes.client.openapi.models.V1SecretBuilder;
|
||||
import org.junit.jupiter.api.Assertions;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.http.HttpMethod;
|
||||
import org.springframework.web.reactive.function.client.WebClient;
|
||||
@@ -71,7 +72,7 @@ final class DataChangesInSecretsReloadDelegate {
|
||||
.withNamespace(NAMESPACE)
|
||||
.withName("event-reload")
|
||||
.build())
|
||||
.withData(Map.of("application.properties", "from.properties.key=initial".getBytes()))
|
||||
.withData(Map.of(Constants.APPLICATION_PROPERTIES, "from.properties.key=initial".getBytes()))
|
||||
.build();
|
||||
|
||||
replaceSecret(secret, "event-reload");
|
||||
@@ -96,7 +97,7 @@ final class DataChangesInSecretsReloadDelegate {
|
||||
.withNamespace(NAMESPACE)
|
||||
.withName("event-reload")
|
||||
.build())
|
||||
.withData(Map.of("application.properties", "from.properties.key=change-initial".getBytes()))
|
||||
.withData(Map.of(Constants.APPLICATION_PROPERTIES, "from.properties.key=change-initial".getBytes()))
|
||||
.build();
|
||||
|
||||
replaceSecret(secret, "event-reload");
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.testcontainers.k3s.K3sContainer;
|
||||
|
||||
import org.springframework.cloud.kubernetes.commons.config.Constants;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Commons;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.Phase;
|
||||
import org.springframework.cloud.kubernetes.integration.tests.commons.native_client.Util;
|
||||
@@ -121,7 +122,7 @@ class K8sClientSecretsReloadIT {
|
||||
|
||||
V1Secret v1Secret = (V1Secret) util.yaml("secret.yaml");
|
||||
Map<String, byte[]> secretData = v1Secret.getData();
|
||||
secretData.replace("application.properties", "from.properties.key: after-change".getBytes());
|
||||
secretData.replace(Constants.APPLICATION_PROPERTIES, "from.properties.key: after-change".getBytes());
|
||||
v1Secret.setData(secretData);
|
||||
coreV1Api.replaceNamespacedSecret("event-reload", NAMESPACE, v1Secret, null, null, null, null);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user