Skip to content

Commit 38889c0

Browse files
committed
fix-1715 : first test
Signed-off-by: wind57 <[email protected]>
1 parent d247f2c commit 38889c0

File tree

11 files changed

+30
-36
lines changed

11 files changed

+30
-36
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ public static Set<String> namespaces(KubernetesNamespaceProvider provider, Confi
7070
* </pre>
7171
*/
7272
static MultipleSourcesContainer secretsDataByLabels(CoreV1Api coreV1Api, String namespace,
73-
Map<String, String> labels, Environment environment) {
73+
Map<String, String> labels, Environment environment) {
7474
List<StrippedSourceContainer> strippedSecrets = strippedSecrets(coreV1Api, namespace);
7575
if (strippedSecrets.isEmpty()) {
7676
return MultipleSourcesContainer.empty();
@@ -87,7 +87,7 @@ static MultipleSourcesContainer secretsDataByLabels(CoreV1Api coreV1Api, String
8787
* </pre>
8888
*/
8989
static MultipleSourcesContainer configMapsDataByLabels(CoreV1Api coreV1Api, String namespace,
90-
Map<String, String> labels, Environment environment) {
90+
Map<String, String> labels, Environment environment) {
9191
List<StrippedSourceContainer> strippedConfigMaps = strippedConfigMaps(coreV1Api, namespace);
9292
if (strippedConfigMaps.isEmpty()) {
9393
return MultipleSourcesContainer.empty();

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.springframework.cloud.kubernetes.client.config;
1818

1919
import java.util.Map;
20-
import java.util.Set;
2120
import java.util.function.Supplier;
2221

2322
import org.springframework.cloud.kubernetes.commons.config.LabeledConfigMapNormalizedSource;
@@ -53,8 +52,7 @@ public MultipleSourcesContainer dataSupplier(Map<String, String> labels) {
5352
labels, context.environment());
5453
}
5554

56-
}.compute(source.labels(), source.prefix(), source.target(), source.profileSpecificSources(),
57-
source.failFast(), context.namespace(), context.environment().getActiveProfiles());
55+
}.compute(source.labels(), source.prefix(), source.target(), source.failFast(), context.namespace());
5856
};
5957

6058
}

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.springframework.cloud.kubernetes.client.config;
1818

1919
import java.util.Map;
20-
import java.util.Set;
2120
import java.util.function.Supplier;
2221

2322
import org.springframework.cloud.kubernetes.commons.config.LabeledSecretNormalizedSource;
@@ -60,8 +59,7 @@ public MultipleSourcesContainer dataSupplier(Map<String, String> labels) {
6059
labels, context.environment());
6160
}
6261

63-
}.compute(source.labels(), source.prefix(), source.target(), source.profileSpecificSources(),
64-
source.failFast(), context.namespace(), context.environment().getActiveProfiles());
62+
}.compute(source.labels(), source.prefix(), source.target(), source.failFast(), context.namespace());
6563
};
6664
}
6765

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,8 @@ void secretLabelsTest() {
194194
Map<String, String> labels = new HashMap<>();
195195
labels.put("spring.cloud.kubernetes.secret", "true");
196196

197-
NormalizedSource source = new LabeledSecretNormalizedSource("default", labels, false, ConfigUtils.Prefix.DEFAULT);
197+
NormalizedSource source = new LabeledSecretNormalizedSource("default", labels, false,
198+
ConfigUtils.Prefix.DEFAULT);
198199
KubernetesClientConfigContext context = new KubernetesClientConfigContext(api, source, "default",
199200
new MockEnvironment());
200201

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

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,8 @@ void singleSecretMatchAgainstLabels() {
136136
stubCall(secretList);
137137
CoreV1Api api = new CoreV1Api();
138138

139-
NormalizedSource source = new LabeledSecretNormalizedSource(NAMESPACE, LABELS,
140-
false, ConfigUtils.Prefix.DEFAULT);
139+
NormalizedSource source = new LabeledSecretNormalizedSource(NAMESPACE, LABELS, false,
140+
ConfigUtils.Prefix.DEFAULT);
141141
KubernetesClientConfigContext context = new KubernetesClientConfigContext(api, source, NAMESPACE,
142142
new MockEnvironment());
143143

@@ -169,8 +169,8 @@ void twoSecretsMatchAgainstLabels() {
169169
stubCall(secretList);
170170
CoreV1Api api = new CoreV1Api();
171171

172-
NormalizedSource source = new LabeledSecretNormalizedSource(NAMESPACE, RED_LABEL,
173-
false, ConfigUtils.Prefix.DEFAULT);
172+
NormalizedSource source = new LabeledSecretNormalizedSource(NAMESPACE, RED_LABEL, false,
173+
ConfigUtils.Prefix.DEFAULT);
174174
KubernetesClientConfigContext context = new KubernetesClientConfigContext(api, source, NAMESPACE,
175175
new MockEnvironment());
176176

@@ -195,8 +195,8 @@ void namespaceMatch() {
195195
stubCall(secretList);
196196
CoreV1Api api = new CoreV1Api();
197197

198-
NormalizedSource source = new LabeledSecretNormalizedSource(NAMESPACE + "nope",
199-
LABELS, false, ConfigUtils.Prefix.DEFAULT);
198+
NormalizedSource source = new LabeledSecretNormalizedSource(NAMESPACE + "nope", LABELS, false,
199+
ConfigUtils.Prefix.DEFAULT);
200200
KubernetesClientConfigContext context = new KubernetesClientConfigContext(api, source, NAMESPACE,
201201
new MockEnvironment());
202202

@@ -229,8 +229,7 @@ void testWithPrefix() {
229229
CoreV1Api api = new CoreV1Api();
230230

231231
ConfigUtils.Prefix prefix = ConfigUtils.findPrefix("me", false, false, null);
232-
NormalizedSource source = new LabeledSecretNormalizedSource(NAMESPACE, Map.of("color", "blue"),
233-
false, prefix);
232+
NormalizedSource source = new LabeledSecretNormalizedSource(NAMESPACE, Map.of("color", "blue"), false, prefix);
234233
KubernetesClientConfigContext context = new KubernetesClientConfigContext(api, source, NAMESPACE,
235234
new MockEnvironment());
236235

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.util.List;
2525
import java.util.Map;
2626
import java.util.Optional;
27+
import java.util.Set;
2728
import java.util.function.BiPredicate;
2829
import java.util.function.BooleanSupplier;
2930
import java.util.function.Function;
@@ -255,7 +256,7 @@ static BooleanSupplier rawDataContainsProfileBasedSource(List<String> activeProf
255256
.anyMatch(activeProfile -> ENDS_WITH_PROFILE_AND_EXTENSION.test(keyName, activeProfile)));
256257
}
257258

258-
static String sourceDataName(String target, LinkedHashSet<String> sourceNames, String namespace) {
259+
static String sourceDataName(String target, Set<String> sourceNames, String namespace) {
259260
String sortedNames = sourceNames.stream().sorted().collect(Collectors.joining(PROPERTY_SOURCE_NAME_SEPARATOR));
260261
return sourceName(target, sortedNames, namespace);
261262
}

spring-cloud-kubernetes-fabric8-config/src/main/java/org/springframework/cloud/kubernetes/fabric8/config/LabeledConfigMapContextToSourceDataProvider.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.springframework.cloud.kubernetes.fabric8.config;
1818

1919
import java.util.Map;
20-
import java.util.Set;
2120
import java.util.function.Supplier;
2221

2322
import org.springframework.cloud.kubernetes.commons.config.LabeledConfigMapNormalizedSource;
@@ -60,8 +59,7 @@ public MultipleSourcesContainer dataSupplier(Map<String, String> labels) {
6059
context.environment());
6160
}
6261

63-
}.compute(source.labels(), source.prefix(), source.target(),
64-
source.failFast(), context.namespace());
62+
}.compute(source.labels(), source.prefix(), source.target(), source.failFast(), context.namespace());
6563
};
6664

6765
}

spring-cloud-kubernetes-fabric8-config/src/main/java/org/springframework/cloud/kubernetes/fabric8/config/LabeledSecretContextToSourceDataProvider.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
package org.springframework.cloud.kubernetes.fabric8.config;
1818

1919
import java.util.Map;
20-
import java.util.Set;
2120
import java.util.function.Supplier;
2221

2322
import org.springframework.cloud.kubernetes.commons.config.LabeledSecretNormalizedSource;
@@ -59,8 +58,7 @@ public MultipleSourcesContainer dataSupplier(Map<String, String> labels) {
5958
context.environment());
6059
}
6160

62-
}.compute(source.labels(), source.prefix(), source.target(),
63-
source.failFast(), context.namespace());
61+
}.compute(source.labels(), source.prefix(), source.target(), source.failFast(), context.namespace());
6462
};
6563

6664
}

spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/Fabric8SecretsPropertySourceMockTests.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void labeledStrategyShouldThrowExceptionOnFailureWhenFailFastIsEnabled() {
7272
final String path = String.format("/api/v1/namespaces/%s/secrets", namespace);
7373

7474
LabeledSecretNormalizedSource labeled = new LabeledSecretNormalizedSource(namespace, labels, true,
75-
ConfigUtils.Prefix.DEFAULT);
75+
ConfigUtils.Prefix.DEFAULT);
7676
Fabric8ConfigContext context = new Fabric8ConfigContext(client, labeled, "default", new MockEnvironment());
7777

7878
mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").always();
@@ -100,7 +100,7 @@ void labeledStrategyShouldNotThrowExceptionOnFailureWhenFailFastIsDisabled() {
100100
final String path = String.format("/api/v1/namespaces/%s/secrets", namespace);
101101

102102
LabeledSecretNormalizedSource labeled = new LabeledSecretNormalizedSource(namespace, labels, false,
103-
ConfigUtils.Prefix.DEFAULT);
103+
ConfigUtils.Prefix.DEFAULT);
104104
Fabric8ConfigContext context = new Fabric8ConfigContext(client, labeled, "default", new MockEnvironment());
105105

106106
mockServer.expect().withPath(path).andReturn(500, "Internal Server Error").always();

spring-cloud-kubernetes-fabric8-config/src/test/java/org/springframework/cloud/kubernetes/fabric8/config/LabeledSecretContextToSourceDataProviderTests.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,8 @@ void singleSecretMatchAgainstLabels() {
107107

108108
mockClient.secrets().inNamespace(NAMESPACE).resource(secret).create();
109109

110-
NormalizedSource normalizedSource = new LabeledSecretNormalizedSource(NAMESPACE, LABELS,
111-
true, ConfigUtils.Prefix.DEFAULT);
110+
NormalizedSource normalizedSource = new LabeledSecretNormalizedSource(NAMESPACE, LABELS, true,
111+
ConfigUtils.Prefix.DEFAULT);
112112
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, normalizedSource, NAMESPACE,
113113
new MockEnvironment());
114114

@@ -153,8 +153,8 @@ void twoSecretsMatchAgainstLabels() {
153153
mockClient.secrets().inNamespace(NAMESPACE).resource(redTwo).create();
154154
mockClient.secrets().inNamespace(NAMESPACE).resource(blue).create();
155155

156-
NormalizedSource normalizedSource = new LabeledSecretNormalizedSource(NAMESPACE, RED_LABEL,
157-
true, ConfigUtils.Prefix.DEFAULT);
156+
NormalizedSource normalizedSource = new LabeledSecretNormalizedSource(NAMESPACE, RED_LABEL, true,
157+
ConfigUtils.Prefix.DEFAULT);
158158
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, normalizedSource, NAMESPACE,
159159
new MockEnvironment());
160160

@@ -183,8 +183,8 @@ void secretNoMatch() {
183183

184184
mockClient.secrets().inNamespace(NAMESPACE).resource(pink).create();
185185

186-
NormalizedSource normalizedSource = new LabeledSecretNormalizedSource(NAMESPACE, BLUE_LABEL,
187-
true, ConfigUtils.Prefix.DEFAULT);
186+
NormalizedSource normalizedSource = new LabeledSecretNormalizedSource(NAMESPACE, BLUE_LABEL, true,
187+
ConfigUtils.Prefix.DEFAULT);
188188
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, normalizedSource, NAMESPACE,
189189
new MockEnvironment());
190190

@@ -214,8 +214,8 @@ void namespaceMatch() {
214214
mockClient.secrets().inNamespace(NAMESPACE).resource(secret).create();
215215

216216
// different namespace
217-
NormalizedSource normalizedSource = new LabeledSecretNormalizedSource(NAMESPACE + "nope", LABELS,
218-
true, ConfigUtils.Prefix.DEFAULT);
217+
NormalizedSource normalizedSource = new LabeledSecretNormalizedSource(NAMESPACE + "nope", LABELS, true,
218+
ConfigUtils.Prefix.DEFAULT);
219219
Fabric8ConfigContext context = new Fabric8ConfigContext(mockClient, normalizedSource, NAMESPACE,
220220
new MockEnvironment());
221221

0 commit comments

Comments
 (0)