Skip to content

Commit 092dc3a

Browse files
committed
Merge branch 'main' into move-to-a-common-configuration-for-health
2 parents c148ded + 2847f75 commit 092dc3a

File tree

33 files changed

+92
-78
lines changed

33 files changed

+92
-78
lines changed

spring-cloud-kubernetes-client-config/src/main/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapsCache.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818

1919
import java.util.List;
2020
import java.util.concurrent.ConcurrentHashMap;
21-
import java.util.stream.Collectors;
2221

2322
import io.kubernetes.client.openapi.ApiException;
2423
import io.kubernetes.client.openapi.apis.CoreV1Api;
@@ -79,7 +78,7 @@ private static List<StrippedSourceContainer> strippedConfigMaps(List<V1ConfigMap
7978
return configMaps.stream()
8079
.map(configMap -> new StrippedSourceContainer(configMap.getMetadata().getLabels(),
8180
configMap.getMetadata().getName(), configMap.getData()))
82-
.collect(Collectors.toList());
81+
.toList();
8382
}
8483

8584
}

spring-cloud-kubernetes-client-config/src/main/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientSecretsCache.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private static List<StrippedSourceContainer> strippedSecrets(List<V1Secret> secr
8080
return secrets.stream()
8181
.map(secret -> new StrippedSourceContainer(secret.getMetadata().getLabels(), secret.getMetadata().getName(),
8282
transform(secret.getData())))
83-
.collect(Collectors.toList());
83+
.toList();
8484
}
8585

8686
private static Map<String, String> transform(Map<String, byte[]> in) {

spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceLocatorTests.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737

3838
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
3939
import org.springframework.cloud.kubernetes.commons.config.ConfigMapConfigProperties;
40+
import org.springframework.cloud.kubernetes.commons.config.Constants;
4041
import org.springframework.cloud.kubernetes.commons.config.NamespaceResolutionFailedException;
4142
import org.springframework.cloud.kubernetes.commons.config.RetryProperties;
4243
import org.springframework.core.env.PropertySource;
@@ -62,7 +63,7 @@ class KubernetesClientConfigMapPropertySourceLocatorTests {
6263
.withNamespace("default")
6364
.withResourceVersion("1")
6465
.build())
65-
.addToData("application.properties",
66+
.addToData(Constants.APPLICATION_PROPERTIES,
6667
"spring.cloud.kubernetes.configuration.watcher.refreshDelay=0\n"
6768
+ "logging.level.org.springframework.cloud.kubernetes=TRACE")
6869
.build());

spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/KubernetesClientConfigMapPropertySourceTests.java

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import org.junit.jupiter.api.Test;
3333

3434
import org.springframework.cloud.kubernetes.commons.config.ConfigUtils;
35+
import org.springframework.cloud.kubernetes.commons.config.Constants;
3536
import org.springframework.cloud.kubernetes.commons.config.NamedConfigMapNormalizedSource;
3637
import org.springframework.cloud.kubernetes.commons.config.NormalizedSource;
3738
import org.springframework.mock.env.MockEnvironment;
@@ -59,7 +60,7 @@ class KubernetesClientConfigMapPropertySourceTests {
5960
.withNamespace("default")
6061
.withResourceVersion("1")
6162
.build())
62-
.addToData("application.properties",
63+
.addToData(Constants.APPLICATION_PROPERTIES,
6364
"spring.cloud.kubernetes.configuration.watcher.refreshDelay=0\n"
6465
+ "logging.level.org.springframework.cloud.kubernetes=TRACE")
6566
.build());
@@ -70,7 +71,8 @@ class KubernetesClientConfigMapPropertySourceTests {
7071
.withNamespace("default")
7172
.withResourceVersion("1")
7273
.build())
73-
.addToData("application.yaml", "dummy:\n property:\n string2: \"a\"\n int2: 1\n bool2: true\n")
74+
.addToData(Constants.APPLICATION_YAML,
75+
"dummy:\n property:\n string2: \"a\"\n int2: 1\n bool2: true\n")
7476
.build());
7577

7678
private static WireMockServer wireMockServer;

spring-cloud-kubernetes-client-config/src/test/java/org/springframework/cloud/kubernetes/client/config/reload/KubernetesClientEventBasedConfigMapChangeDetectorTests.java

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@
5151
import org.springframework.cloud.kubernetes.client.config.KubernetesClientConfigMapPropertySource;
5252
import org.springframework.cloud.kubernetes.client.config.KubernetesClientConfigMapPropertySourceLocator;
5353
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
54+
import org.springframework.cloud.kubernetes.commons.config.Constants;
5455
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadProperties;
5556
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigurationUpdateStrategy;
5657
import org.springframework.mock.env.MockPropertySource;
@@ -99,11 +100,12 @@ void watch() {
99100
Gson gson = builder.create();
100101

101102
Map<String, String> data = new HashMap<>();
102-
data.put("application.properties", "spring.cloud.kubernetes.configuration.watcher.refreshDelay=0\n"
103+
data.put(Constants.APPLICATION_PROPERTIES, "spring.cloud.kubernetes.configuration.watcher.refreshDelay=0\n"
103104
+ "logging.level.org.springframework.cloud.kubernetes=TRACE");
104105
Map<String, String> updateData = new HashMap<>();
105-
updateData.put("application.properties", "spring.cloud.kubernetes.configuration.watcher.refreshDelay=1\n"
106-
+ "logging.level.org.springframework.cloud.kubernetes=TRACE");
106+
updateData.put(Constants.APPLICATION_PROPERTIES,
107+
"spring.cloud.kubernetes.configuration.watcher.refreshDelay=1\n"
108+
+ "logging.level.org.springframework.cloud.kubernetes=TRACE");
107109
V1ConfigMap applicationConfig = new V1ConfigMap().kind("ConfigMap")
108110
.metadata(new V1ObjectMeta().namespace("default").name("bar1"))
109111
.data(data);
@@ -132,7 +134,7 @@ void watch() {
132134
.withBody(new JSON().serialize(new Watch.Response<>(EventType.ADDED.name(),
133135
new V1ConfigMap().kind("ConfigMap")
134136
.metadata(new V1ObjectMeta().namespace("default").name("bar3"))
135-
.putDataItem("application.properties", "debug=true")))))
137+
.putDataItem(Constants.APPLICATION_PROPERTIES, "debug=true")))))
136138
.willSetStateTo("delete"));
137139

138140
stubFor(get(urlMatching("^/api/v1/namespaces/default/configmaps.*")).inScenario("watch")
@@ -142,7 +144,7 @@ void watch() {
142144
.withBody(new JSON().serialize(new Watch.Response<>(EventType.DELETED.name(),
143145
new V1ConfigMap().kind("ConfigMap")
144146
.metadata(new V1ObjectMeta().namespace("default").name("bar1"))
145-
.putDataItem("application.properties", "debug=true")))))
147+
.putDataItem(Constants.APPLICATION_PROPERTIES, "debug=true")))))
146148
.willSetStateTo("done"));
147149

148150
stubFor(get(urlMatching("^/api/v1/namespaces/default/configmaps.*")).inScenario("watch")

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/ConfigMapConfigProperties.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121
import java.util.Map;
22-
import java.util.stream.Collectors;
2322
import java.util.stream.Stream;
2423

2524
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -67,7 +66,7 @@ public List<NormalizedSource> determineSources(Environment environment) {
6766
return this.sources.stream()
6867
.flatMap(s -> s.normalize(this.name, this.namespace, this.labels, this.includeProfileSpecificSources,
6968
this.failFast, this.useNameAsPrefix, environment))
70-
.collect(Collectors.toList());
69+
.toList();
7170
}
7271

7372
/**

spring-cloud-kubernetes-commons/src/main/java/org/springframework/cloud/kubernetes/commons/config/SecretsConfigProperties.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
import java.util.ArrayList;
2020
import java.util.List;
2121
import java.util.Map;
22-
import java.util.stream.Collectors;
2322
import java.util.stream.Stream;
2423

2524
import org.springframework.boot.context.properties.ConfigurationProperties;
@@ -68,7 +67,7 @@ public List<NormalizedSource> determineSources(Environment environment) {
6867
return this.sources.stream()
6968
.flatMap(s -> s.normalize(this.name, this.namespace, this.labels, this.includeProfileSpecificSources,
7069
this.failFast, this.useNameAsPrefix, environment))
71-
.collect(Collectors.toList());
70+
.toList();
7271
}
7372

7473
/**

spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/ConfigUtilsTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,10 +179,10 @@ void testWithPrefixSortedName() {
179179
void testMerge() {
180180

181181
StrippedSourceContainer configMapOne = new StrippedSourceContainer(Map.of(), "configmap-one",
182-
Map.of("application.yaml", "propA: A\npropB: B"));
182+
Map.of(Constants.APPLICATION_YAML, "propA: A\npropB: B"));
183183

184184
StrippedSourceContainer configMapOneK8s = new StrippedSourceContainer(Map.of(), "configmap-one-kubernetes",
185-
Map.of("application.yaml", "propA: AA\npropC: C"));
185+
Map.of(Constants.APPLICATION_YAML, "propA: AA\npropC: C"));
186186

187187
LinkedHashSet<String> sourceNames = Stream.of("configmap-one", "configmap-one-kubernetes")
188188
.collect(Collectors.toCollection(LinkedHashSet::new));

spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessorOrderedPropertiesTests.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ void testSingleNonFileProperty() {
5353
@Test
5454
void testSingleFileProperty() {
5555
Map<String, String> map = new LinkedHashMap<>();
56-
map.put("application.properties", "my-key=from-app");
56+
map.put(Constants.APPLICATION_PROPERTIES, "my-key=from-app");
5757

5858
MockEnvironment mockEnvironment = new MockEnvironment();
5959
Map<String, Object> result = SourceDataEntriesProcessor.processAllEntries(map, mockEnvironment);
@@ -78,7 +78,7 @@ void testSingleFileProperty() {
7878
void testThree() {
7979

8080
Map<String, String> map = new LinkedHashMap<>();
81-
map.put("application.properties", """
81+
map.put(Constants.APPLICATION_PROPERTIES, """
8282
firstKey=firstFromProperties
8383
secondKey=secondFromProperties""");
8484
map.put("firstKey", "abc");
@@ -114,7 +114,7 @@ void testThree() {
114114
void testFour() {
115115

116116
Map<String, String> map = new LinkedHashMap<>();
117-
map.put("application.properties", """
117+
map.put(Constants.APPLICATION_PROPERTIES, """
118118
firstKey=firstFromProperties
119119
secondKey=secondFromProperties
120120
thirdKey=thirdFromProperties""");
@@ -158,7 +158,7 @@ void testFour() {
158158
void testFive() {
159159

160160
Map<String, String> map = new LinkedHashMap<>();
161-
map.put("application.properties", """
161+
map.put(Constants.APPLICATION_PROPERTIES, """
162162
firstKey=firstFromProperties
163163
secondKey=secondFromProperties
164164
thirdKey=thirdFromProperties""");

spring-cloud-kubernetes-commons/src/test/java/org/springframework/cloud/kubernetes/commons/config/SourceDataEntriesProcessorSortedTests.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -66,28 +66,28 @@ void testTwoNonFileProperties() {
6666
void testSingleFileProperty() {
6767

6868
Map<String, String> k8sSource = new LinkedHashMap<>();
69-
k8sSource.put("application.properties", "key=value");
69+
k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value");
7070

7171
MockEnvironment mockEnvironment = new MockEnvironment();
7272

7373
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
7474
Assertions.assertEquals(result.size(), 1);
75-
Assertions.assertEquals(result.get(0).getKey(), "application.properties");
75+
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
7676
Assertions.assertEquals(result.get(0).getValue(), "key=value");
7777
}
7878

7979
@Test
8080
void testApplicationAndSimpleProperty() {
8181

8282
Map<String, String> k8sSource = new LinkedHashMap<>();
83-
k8sSource.put("application.properties", "key=value");
83+
k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value");
8484
k8sSource.put("simple", "other_value");
8585

8686
MockEnvironment mockEnvironment = new MockEnvironment();
8787

8888
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
8989
Assertions.assertEquals(result.size(), 2);
90-
Assertions.assertEquals(result.get(0).getKey(), "application.properties");
90+
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
9191
Assertions.assertEquals(result.get(0).getValue(), "key=value");
9292

9393
Assertions.assertEquals(result.get(1).getKey(), "simple");
@@ -99,13 +99,13 @@ void testSimplePropertyAndApplication() {
9999

100100
Map<String, String> k8sSource = new LinkedHashMap<>();
101101
k8sSource.put("simple", "other_value");
102-
k8sSource.put("application.properties", "key=value");
102+
k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value");
103103

104104
MockEnvironment mockEnvironment = new MockEnvironment();
105105

106106
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
107107
Assertions.assertEquals(result.size(), 2);
108-
Assertions.assertEquals(result.get(0).getKey(), "application.properties");
108+
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
109109
Assertions.assertEquals(result.get(0).getValue(), "key=value");
110110

111111
Assertions.assertEquals(result.get(1).getKey(), "simple");
@@ -117,15 +117,15 @@ void testSimplePropertyAndTwoApplications() {
117117

118118
Map<String, String> k8sSource = new LinkedHashMap<>();
119119
k8sSource.put("simple", "other_value");
120-
k8sSource.put("application.properties", "key=value");
120+
k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value");
121121
k8sSource.put("application-dev.properties", "key-dev=value-dev");
122122

123123
MockEnvironment mockEnvironment = new MockEnvironment();
124124
mockEnvironment.setActiveProfiles("dev");
125125

126126
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
127127
Assertions.assertEquals(result.size(), 3);
128-
Assertions.assertEquals(result.get(0).getKey(), "application.properties");
128+
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
129129
Assertions.assertEquals(result.get(0).getValue(), "key=value");
130130

131131
Assertions.assertEquals(result.get(1).getKey(), "application-dev.properties");
@@ -140,7 +140,7 @@ void testSimplePropertyAndTwoApplicationsDoNotIncludeDefaultProfile() {
140140

141141
Map<String, String> k8sSource = new LinkedHashMap<>();
142142
k8sSource.put("simple", "other_value");
143-
k8sSource.put("application.properties", "key=value");
143+
k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value");
144144
k8sSource.put("application-dev.properties", "key-dev=value-dev");
145145

146146
MockEnvironment mockEnvironment = new MockEnvironment();
@@ -159,7 +159,7 @@ void testComplex() {
159159
Map<String, String> k8sSource = new LinkedHashMap<>();
160160
k8sSource.put("simple", "other_value");
161161
k8sSource.put("second-simple", "second_other_value");
162-
k8sSource.put("application.properties", "key=value");
162+
k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value");
163163
k8sSource.put("application-dev.properties", "key-dev=value-dev");
164164
k8sSource.put("application-k8s.properties", "key-k8s=value-k8s");
165165
k8sSource.put("ignored.properties", "key-ignored=value-ignored");
@@ -169,7 +169,7 @@ void testComplex() {
169169

170170
List<Map.Entry<String, String>> result = SourceDataEntriesProcessor.sorted(k8sSource, mockEnvironment);
171171
Assertions.assertEquals(result.size(), 4);
172-
Assertions.assertEquals(result.get(0).getKey(), "application.properties");
172+
Assertions.assertEquals(result.get(0).getKey(), Constants.APPLICATION_PROPERTIES);
173173
Assertions.assertEquals(result.get(0).getValue(), "key=value");
174174

175175
Assertions.assertEquals(result.get(1).getKey(), "application-k8s.properties");
@@ -188,7 +188,7 @@ void testComplexWithNonDefaultApplicationName() {
188188
Map<String, String> k8sSource = new LinkedHashMap<>();
189189
k8sSource.put("simple", "other_value");
190190
k8sSource.put("second-simple", "second_other_value");
191-
k8sSource.put("application.properties", "key=value");
191+
k8sSource.put(Constants.APPLICATION_PROPERTIES, "key=value");
192192
k8sSource.put("application-dev.properties", "key-dev=value-dev");
193193
k8sSource.put("application-k8s.properties", "key-k8s=value-k8s");
194194
k8sSource.put("ignored.properties", "key-ignored=value-ignored");

0 commit comments

Comments
 (0)