Skip to content

Commit 7094146

Browse files
committed
dirty
1 parent e21af59 commit 7094146

File tree

8 files changed

+757
-149
lines changed

8 files changed

+757
-149
lines changed

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

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -55,53 +55,53 @@ class KubernetesClientSecretsPropertySourceLocatorTests {
5555
private static final String LIST_API = "/api/v1/namespaces/default/secrets";
5656

5757
private static final String LIST_BODY = """
58-
{
59-
\t"kind": "SecretList",
60-
\t"apiVersion": "v1",
61-
\t"metadata": {
62-
\t\t"selfLink": "/api/v1/secrets",
63-
\t\t"resourceVersion": "163035"
64-
\t},
65-
\t"items": [{
66-
\t\t\t"metadata": {
67-
\t\t\t\t"name": "db-secret",
68-
\t\t\t\t"namespace": "default",
69-
\t\t\t\t"selfLink": "/api/v1/namespaces/default/secrets/db-secret",
70-
\t\t\t\t"uid": "59ba8e6a-a2d4-416c-b016-22597c193f23",
71-
\t\t\t\t"resourceVersion": "1462",
72-
\t\t\t\t"creationTimestamp": "2020-10-28T14:45:02Z",
73-
\t\t\t\t"labels": {
74-
\t\t\t\t\t"spring.cloud.kubernetes.secret": "true"
75-
\t\t\t\t}
76-
\t\t\t},
77-
\t\t\t"data": {
78-
\t\t\t\t"password": "cDQ1NXcwcmQ=",
79-
\t\t\t\t"username": "dXNlcg=="
80-
\t\t\t},
81-
\t\t\t"type": "Opaque"
82-
\t\t},
83-
\t\t{
84-
\t\t\t"metadata": {
85-
\t\t\t\t"name": "rabbit-password",
86-
\t\t\t\t"namespace": "default",
87-
\t\t\t\t"selfLink": "/api/v1/namespaces/default/secrets/rabbit-password",
88-
\t\t\t\t"uid": "bc211cb4-e7ff-4556-b26e-c54911301740",
89-
\t\t\t\t"resourceVersion": "162708",
90-
\t\t\t\t"creationTimestamp": "2020-10-29T19:47:36Z",
91-
\t\t\t\t"labels": {
92-
\t\t\t\t\t"spring.cloud.kubernetes.secret": "true"
93-
\t\t\t\t},
94-
\t\t\t\t"annotations": {
95-
\t\t\t\t\t"kubectl.kubernetes.io/last-applied-configuration": "{\\"apiVersion\\":\\"v1\\",\\"data\\":{\\"spring.rabbitmq.password\\":\\"password\\"},\\"kind\\":\\"Secret\\",\\"metadata\\":{\\"annotations\\":{},\\"labels\\":{\\"spring.cloud.kubernetes.secret\\":\\"true\\"},\\"name\\":\\"rabbit-password\\",\\"namespace\\":\\"default\\"},\\"type\\":\\"Opaque\\"}\\n"
96-
\t\t\t\t}
97-
\t\t\t},
98-
\t\t\t"data": {
99-
\t\t\t\t"spring.rabbitmq.password": "cGFzc3dvcmQ="
100-
\t\t\t},
101-
\t\t\t"type": "Opaque"
102-
\t\t}
103-
\t]
104-
}""";
58+
{
59+
\t"kind": "SecretList",
60+
\t"apiVersion": "v1",
61+
\t"metadata": {
62+
\t\t"selfLink": "/api/v1/secrets",
63+
\t\t"resourceVersion": "163035"
64+
\t},
65+
\t"items": [{
66+
\t\t\t"metadata": {
67+
\t\t\t\t"name": "db-secret",
68+
\t\t\t\t"namespace": "default",
69+
\t\t\t\t"selfLink": "/api/v1/namespaces/default/secrets/db-secret",
70+
\t\t\t\t"uid": "59ba8e6a-a2d4-416c-b016-22597c193f23",
71+
\t\t\t\t"resourceVersion": "1462",
72+
\t\t\t\t"creationTimestamp": "2020-10-28T14:45:02Z",
73+
\t\t\t\t"labels": {
74+
\t\t\t\t\t"spring.cloud.kubernetes.secret": "true"
75+
\t\t\t\t}
76+
\t\t\t},
77+
\t\t\t"data": {
78+
\t\t\t\t"password": "cDQ1NXcwcmQ=",
79+
\t\t\t\t"username": "dXNlcg=="
80+
\t\t\t},
81+
\t\t\t"type": "Opaque"
82+
\t\t},
83+
\t\t{
84+
\t\t\t"metadata": {
85+
\t\t\t\t"name": "rabbit-password",
86+
\t\t\t\t"namespace": "default",
87+
\t\t\t\t"selfLink": "/api/v1/namespaces/default/secrets/rabbit-password",
88+
\t\t\t\t"uid": "bc211cb4-e7ff-4556-b26e-c54911301740",
89+
\t\t\t\t"resourceVersion": "162708",
90+
\t\t\t\t"creationTimestamp": "2020-10-29T19:47:36Z",
91+
\t\t\t\t"labels": {
92+
\t\t\t\t\t"spring.cloud.kubernetes.secret": "true"
93+
\t\t\t\t},
94+
\t\t\t\t"annotations": {
95+
\t\t\t\t\t"kubectl.kubernetes.io/last-applied-configuration": "{\\"apiVersion\\":\\"v1\\",\\"data\\":{\\"spring.rabbitmq.password\\":\\"password\\"},\\"kind\\":\\"Secret\\",\\"metadata\\":{\\"annotations\\":{},\\"labels\\":{\\"spring.cloud.kubernetes.secret\\":\\"true\\"},\\"name\\":\\"rabbit-password\\",\\"namespace\\":\\"default\\"},\\"type\\":\\"Opaque\\"}\\n"
96+
\t\t\t\t}
97+
\t\t\t},
98+
\t\t\t"data": {
99+
\t\t\t\t"spring.rabbitmq.password": "cGFzc3dvcmQ="
100+
\t\t\t},
101+
\t\t\t"type": "Opaque"
102+
\t\t}
103+
\t]
104+
}""";
105105

106106
private static WireMockServer wireMockServer;
107107

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

Lines changed: 47 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -81,53 +81,53 @@ class KubernetesClientSecretsPropertySourceTests {
8181
private static final String LIST_API_WITH_LABEL = "/api/v1/namespaces/default/secrets";
8282

8383
private static final String LIST_BODY = """
84-
{
85-
\t"kind": "SecretList",
86-
\t"apiVersion": "v1",
87-
\t"metadata": {
88-
\t\t"selfLink": "/api/v1/secrets",
89-
\t\t"resourceVersion": "163035"
90-
\t},
91-
\t"items": [{
92-
\t\t\t"metadata": {
93-
\t\t\t\t"name": "db-secret",
94-
\t\t\t\t"namespace": "default",
95-
\t\t\t\t"selfLink": "/api/v1/namespaces/default/secrets/db-secret",
96-
\t\t\t\t"uid": "59ba8e6a-a2d4-416c-b016-22597c193f23",
97-
\t\t\t\t"resourceVersion": "1462",
98-
\t\t\t\t"creationTimestamp": "2020-10-28T14:45:02Z",
99-
\t\t\t\t"labels": {
100-
\t\t\t\t\t"spring.cloud.kubernetes.secret": "true"
101-
\t\t\t\t}
102-
\t\t\t},
103-
\t\t\t"data": {
104-
\t\t\t\t"password": "cDQ1NXcwcmQ=",
105-
\t\t\t\t"username": "dXNlcg=="
106-
\t\t\t},
107-
\t\t\t"type": "Opaque"
108-
\t\t},
109-
\t\t{
110-
\t\t\t"metadata": {
111-
\t\t\t\t"name": "rabbit-password",
112-
\t\t\t\t"namespace": "default",
113-
\t\t\t\t"selfLink": "/api/v1/namespaces/default/secrets/rabbit-password",
114-
\t\t\t\t"uid": "bc211cb4-e7ff-4556-b26e-c54911301740",
115-
\t\t\t\t"resourceVersion": "162708",
116-
\t\t\t\t"creationTimestamp": "2020-10-29T19:47:36Z",
117-
\t\t\t\t"labels": {
118-
\t\t\t\t\t"spring.cloud.kubernetes.secret": "true"
119-
\t\t\t\t},
120-
\t\t\t\t"annotations": {
121-
\t\t\t\t\t"kubectl.kubernetes.io/last-applied-configuration": "{\\"apiVersion\\":\\"v1\\",\\"data\\":{\\"spring.rabbitmq.password\\":\\"password\\"},\\"kind\\":\\"Secret\\",\\"metadata\\":{\\"annotations\\":{},\\"labels\\":{\\"spring.cloud.kubernetes.secret\\":\\"true\\"},\\"name\\":\\"rabbit-password\\",\\"namespace\\":\\"default\\"},\\"type\\":\\"Opaque\\"}\\n"
122-
\t\t\t\t}
123-
\t\t\t},
124-
\t\t\t"data": {
125-
\t\t\t\t"spring.rabbitmq.password": "cGFzc3dvcmQ="
126-
\t\t\t},
127-
\t\t\t"type": "Opaque"
128-
\t\t}
129-
\t]
130-
}""";
84+
{
85+
\t"kind": "SecretList",
86+
\t"apiVersion": "v1",
87+
\t"metadata": {
88+
\t\t"selfLink": "/api/v1/secrets",
89+
\t\t"resourceVersion": "163035"
90+
\t},
91+
\t"items": [{
92+
\t\t\t"metadata": {
93+
\t\t\t\t"name": "db-secret",
94+
\t\t\t\t"namespace": "default",
95+
\t\t\t\t"selfLink": "/api/v1/namespaces/default/secrets/db-secret",
96+
\t\t\t\t"uid": "59ba8e6a-a2d4-416c-b016-22597c193f23",
97+
\t\t\t\t"resourceVersion": "1462",
98+
\t\t\t\t"creationTimestamp": "2020-10-28T14:45:02Z",
99+
\t\t\t\t"labels": {
100+
\t\t\t\t\t"spring.cloud.kubernetes.secret": "true"
101+
\t\t\t\t}
102+
\t\t\t},
103+
\t\t\t"data": {
104+
\t\t\t\t"password": "cDQ1NXcwcmQ=",
105+
\t\t\t\t"username": "dXNlcg=="
106+
\t\t\t},
107+
\t\t\t"type": "Opaque"
108+
\t\t},
109+
\t\t{
110+
\t\t\t"metadata": {
111+
\t\t\t\t"name": "rabbit-password",
112+
\t\t\t\t"namespace": "default",
113+
\t\t\t\t"selfLink": "/api/v1/namespaces/default/secrets/rabbit-password",
114+
\t\t\t\t"uid": "bc211cb4-e7ff-4556-b26e-c54911301740",
115+
\t\t\t\t"resourceVersion": "162708",
116+
\t\t\t\t"creationTimestamp": "2020-10-29T19:47:36Z",
117+
\t\t\t\t"labels": {
118+
\t\t\t\t\t"spring.cloud.kubernetes.secret": "true"
119+
\t\t\t\t},
120+
\t\t\t\t"annotations": {
121+
\t\t\t\t\t"kubectl.kubernetes.io/last-applied-configuration": "{\\"apiVersion\\":\\"v1\\",\\"data\\":{\\"spring.rabbitmq.password\\":\\"password\\"},\\"kind\\":\\"Secret\\",\\"metadata\\":{\\"annotations\\":{},\\"labels\\":{\\"spring.cloud.kubernetes.secret\\":\\"true\\"},\\"name\\":\\"rabbit-password\\",\\"namespace\\":\\"default\\"},\\"type\\":\\"Opaque\\"}\\n"
122+
\t\t\t\t}
123+
\t\t\t},
124+
\t\t\t"data": {
125+
\t\t\t\t"spring.rabbitmq.password": "cGFzc3dvcmQ="
126+
\t\t\t},
127+
\t\t\t"type": "Opaque"
128+
\t\t}
129+
\t]
130+
}""";
131131

132132
private static WireMockServer wireMockServer;
133133

Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*
2+
* Copyright 2013-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.cloud.kubernetes.client.config;
18+
19+
import io.kubernetes.client.common.KubernetesObject;
20+
import io.kubernetes.client.openapi.apis.CoreV1Api;
21+
22+
import org.springframework.cloud.kubernetes.client.config.reload.KubernetesClientEventBasedConfigMapChangeDetector;
23+
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
24+
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadProperties;
25+
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigurationUpdateStrategy;
26+
import org.springframework.core.env.ConfigurableEnvironment;
27+
28+
/**
29+
* @author wind57
30+
*/
31+
public class VisibleKubernetesClientEventBasedConfigMapChangeDetector
32+
extends KubernetesClientEventBasedConfigMapChangeDetector {
33+
34+
public VisibleKubernetesClientEventBasedConfigMapChangeDetector(CoreV1Api coreV1Api,
35+
ConfigurableEnvironment environment, ConfigReloadProperties properties,
36+
ConfigurationUpdateStrategy strategy, KubernetesClientConfigMapPropertySourceLocator propertySourceLocator,
37+
KubernetesNamespaceProvider kubernetesNamespaceProvider) {
38+
super(coreV1Api, environment, properties, strategy, propertySourceLocator, kubernetesNamespaceProvider);
39+
}
40+
41+
public void onEvent(KubernetesObject kubernetesObject) {
42+
super.onEvent(kubernetesObject);
43+
}
44+
45+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2013-2022 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.cloud.kubernetes.client.config;
18+
19+
import io.kubernetes.client.common.KubernetesObject;
20+
import io.kubernetes.client.openapi.apis.CoreV1Api;
21+
22+
import org.springframework.cloud.kubernetes.client.config.reload.KubernetesClientEventBasedSecretsChangeDetector;
23+
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
24+
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadProperties;
25+
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigurationUpdateStrategy;
26+
import org.springframework.core.env.ConfigurableEnvironment;
27+
28+
/**
29+
* @author wind57
30+
*/
31+
public class VisibleKubernetesClientEventBasedSecretsChangeDetector
32+
extends KubernetesClientEventBasedSecretsChangeDetector {
33+
34+
public VisibleKubernetesClientEventBasedSecretsChangeDetector(CoreV1Api coreV1Api,
35+
ConfigurableEnvironment environment, ConfigReloadProperties properties,
36+
ConfigurationUpdateStrategy strategy, KubernetesClientSecretsPropertySourceLocator propertySourceLocator,
37+
KubernetesNamespaceProvider kubernetesNamespaceProvider) {
38+
super(coreV1Api, environment, properties, strategy, propertySourceLocator, kubernetesNamespaceProvider);
39+
}
40+
41+
@Override
42+
public void onEvent(KubernetesObject kubernetesObject) {
43+
super.onEvent(kubernetesObject);
44+
}
45+
46+
}

0 commit comments

Comments
 (0)