Skip to content

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,54 @@ class KubernetesClientSecretsPropertySourceLocatorTests {

private static final String LIST_API = "/api/v1/namespaces/default/secrets";

private static final String LIST_BODY = "{\n" + "\t\"kind\": \"SecretList\",\n" + "\t\"apiVersion\": \"v1\",\n"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just formatting, nothing else changed here

+ "\t\"metadata\": {\n" + "\t\t\"selfLink\": \"/api/v1/secrets\",\n"
+ "\t\t\"resourceVersion\": \"163035\"\n" + "\t},\n" + "\t\"items\": [{\n" + "\t\t\t\"metadata\": {\n"
+ "\t\t\t\t\"name\": \"db-secret\",\n" + "\t\t\t\t\"namespace\": \"default\",\n"
+ "\t\t\t\t\"selfLink\": \"/api/v1/namespaces/default/secrets/db-secret\",\n"
+ "\t\t\t\t\"uid\": \"59ba8e6a-a2d4-416c-b016-22597c193f23\",\n"
+ "\t\t\t\t\"resourceVersion\": \"1462\",\n" + "\t\t\t\t\"creationTimestamp\": \"2020-10-28T14:45:02Z\",\n"
+ "\t\t\t\t\"labels\": {\n" + "\t\t\t\t\t\"spring.cloud.kubernetes.secret\": \"true\"\n" + "\t\t\t\t}\n"
+ "\t\t\t},\n" + "\t\t\t\"data\": {\n" + "\t\t\t\t\"password\": \"cDQ1NXcwcmQ=\",\n"
+ "\t\t\t\t\"username\": \"dXNlcg==\"\n" + "\t\t\t},\n" + "\t\t\t\"type\": \"Opaque\"\n" + "\t\t},\n"
+ "\t\t{\n" + "\t\t\t\"metadata\": {\n" + "\t\t\t\t\"name\": \"rabbit-password\",\n"
+ "\t\t\t\t\"namespace\": \"default\",\n"
+ "\t\t\t\t\"selfLink\": \"/api/v1/namespaces/default/secrets/rabbit-password\",\n"
+ "\t\t\t\t\"uid\": \"bc211cb4-e7ff-4556-b26e-c54911301740\",\n"
+ "\t\t\t\t\"resourceVersion\": \"162708\",\n"
+ "\t\t\t\t\"creationTimestamp\": \"2020-10-29T19:47:36Z\",\n" + "\t\t\t\t\"labels\": {\n"
+ "\t\t\t\t\t\"spring.cloud.kubernetes.secret\": \"true\"\n" + "\t\t\t\t},\n"
+ "\t\t\t\t\"annotations\": {\n"
+ "\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\"\n"
+ "\t\t\t\t}\n" + "\t\t\t},\n" + "\t\t\t\"data\": {\n"
+ "\t\t\t\t\"spring.rabbitmq.password\": \"cGFzc3dvcmQ=\"\n" + "\t\t\t},\n" + "\t\t\t\"type\": \"Opaque\"\n"
+ "\t\t}\n" + "\t]\n" + "}";
private static final String LIST_BODY = """
{
\t"kind": "SecretList",
\t"apiVersion": "v1",
\t"metadata": {
\t\t"selfLink": "/api/v1/secrets",
\t\t"resourceVersion": "163035"
\t},
\t"items": [{
\t\t\t"metadata": {
\t\t\t\t"name": "db-secret",
\t\t\t\t"namespace": "default",
\t\t\t\t"selfLink": "/api/v1/namespaces/default/secrets/db-secret",
\t\t\t\t"uid": "59ba8e6a-a2d4-416c-b016-22597c193f23",
\t\t\t\t"resourceVersion": "1462",
\t\t\t\t"creationTimestamp": "2020-10-28T14:45:02Z",
\t\t\t\t"labels": {
\t\t\t\t\t"spring.cloud.kubernetes.secret": "true"
\t\t\t\t}
\t\t\t},
\t\t\t"data": {
\t\t\t\t"password": "cDQ1NXcwcmQ=",
\t\t\t\t"username": "dXNlcg=="
\t\t\t},
\t\t\t"type": "Opaque"
\t\t},
\t\t{
\t\t\t"metadata": {
\t\t\t\t"name": "rabbit-password",
\t\t\t\t"namespace": "default",
\t\t\t\t"selfLink": "/api/v1/namespaces/default/secrets/rabbit-password",
\t\t\t\t"uid": "bc211cb4-e7ff-4556-b26e-c54911301740",
\t\t\t\t"resourceVersion": "162708",
\t\t\t\t"creationTimestamp": "2020-10-29T19:47:36Z",
\t\t\t\t"labels": {
\t\t\t\t\t"spring.cloud.kubernetes.secret": "true"
\t\t\t\t},
\t\t\t\t"annotations": {
\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"
\t\t\t\t}
\t\t\t},
\t\t\t"data": {
\t\t\t\t"spring.rabbitmq.password": "cGFzc3dvcmQ="
\t\t\t},
\t\t\t"type": "Opaque"
\t\t}
\t]
}""";

private static WireMockServer wireMockServer;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,28 +80,54 @@ class KubernetesClientSecretsPropertySourceTests {

private static final String LIST_API_WITH_LABEL = "/api/v1/namespaces/default/secrets";

private static final String LIST_BODY = "{\n" + "\t\"kind\": \"SecretList\",\n" + "\t\"apiVersion\": \"v1\",\n"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting only

+ "\t\"metadata\": {\n" + "\t\t\"selfLink\": \"/api/v1/secrets\",\n"
+ "\t\t\"resourceVersion\": \"163035\"\n" + "\t},\n" + "\t\"items\": [{\n" + "\t\t\t\"metadata\": {\n"
+ "\t\t\t\t\"name\": \"db-secret\",\n" + "\t\t\t\t\"namespace\": \"default\",\n"
+ "\t\t\t\t\"selfLink\": \"/api/v1/namespaces/default/secrets/db-secret\",\n"
+ "\t\t\t\t\"uid\": \"59ba8e6a-a2d4-416c-b016-22597c193f23\",\n"
+ "\t\t\t\t\"resourceVersion\": \"1462\",\n" + "\t\t\t\t\"creationTimestamp\": \"2020-10-28T14:45:02Z\",\n"
+ "\t\t\t\t\"labels\": {\n" + "\t\t\t\t\t\"spring.cloud.kubernetes.secret\": \"true\"\n" + "\t\t\t\t}\n"
+ "\t\t\t},\n" + "\t\t\t\"data\": {\n" + "\t\t\t\t\"password\": \"cDQ1NXcwcmQ=\",\n"
+ "\t\t\t\t\"username\": \"dXNlcg==\"\n" + "\t\t\t},\n" + "\t\t\t\"type\": \"Opaque\"\n" + "\t\t},\n"
+ "\t\t{\n" + "\t\t\t\"metadata\": {\n" + "\t\t\t\t\"name\": \"rabbit-password\",\n"
+ "\t\t\t\t\"namespace\": \"default\",\n"
+ "\t\t\t\t\"selfLink\": \"/api/v1/namespaces/default/secrets/rabbit-password\",\n"
+ "\t\t\t\t\"uid\": \"bc211cb4-e7ff-4556-b26e-c54911301740\",\n"
+ "\t\t\t\t\"resourceVersion\": \"162708\",\n"
+ "\t\t\t\t\"creationTimestamp\": \"2020-10-29T19:47:36Z\",\n" + "\t\t\t\t\"labels\": {\n"
+ "\t\t\t\t\t\"spring.cloud.kubernetes.secret\": \"true\"\n" + "\t\t\t\t},\n"
+ "\t\t\t\t\"annotations\": {\n"
+ "\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\"\n"
+ "\t\t\t\t}\n" + "\t\t\t},\n" + "\t\t\t\"data\": {\n"
+ "\t\t\t\t\"spring.rabbitmq.password\": \"cGFzc3dvcmQ=\"\n" + "\t\t\t},\n" + "\t\t\t\"type\": \"Opaque\"\n"
+ "\t\t}\n" + "\t]\n" + "}";
private static final String LIST_BODY = """
{
\t"kind": "SecretList",
\t"apiVersion": "v1",
\t"metadata": {
\t\t"selfLink": "/api/v1/secrets",
\t\t"resourceVersion": "163035"
\t},
\t"items": [{
\t\t\t"metadata": {
\t\t\t\t"name": "db-secret",
\t\t\t\t"namespace": "default",
\t\t\t\t"selfLink": "/api/v1/namespaces/default/secrets/db-secret",
\t\t\t\t"uid": "59ba8e6a-a2d4-416c-b016-22597c193f23",
\t\t\t\t"resourceVersion": "1462",
\t\t\t\t"creationTimestamp": "2020-10-28T14:45:02Z",
\t\t\t\t"labels": {
\t\t\t\t\t"spring.cloud.kubernetes.secret": "true"
\t\t\t\t}
\t\t\t},
\t\t\t"data": {
\t\t\t\t"password": "cDQ1NXcwcmQ=",
\t\t\t\t"username": "dXNlcg=="
\t\t\t},
\t\t\t"type": "Opaque"
\t\t},
\t\t{
\t\t\t"metadata": {
\t\t\t\t"name": "rabbit-password",
\t\t\t\t"namespace": "default",
\t\t\t\t"selfLink": "/api/v1/namespaces/default/secrets/rabbit-password",
\t\t\t\t"uid": "bc211cb4-e7ff-4556-b26e-c54911301740",
\t\t\t\t"resourceVersion": "162708",
\t\t\t\t"creationTimestamp": "2020-10-29T19:47:36Z",
\t\t\t\t"labels": {
\t\t\t\t\t"spring.cloud.kubernetes.secret": "true"
\t\t\t\t},
\t\t\t\t"annotations": {
\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"
\t\t\t\t}
\t\t\t},
\t\t\t"data": {
\t\t\t\t"spring.rabbitmq.password": "cGFzc3dvcmQ="
\t\t\t},
\t\t\t"type": "Opaque"
\t\t}
\t]
}""";

private static WireMockServer wireMockServer;

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
/*
* Copyright 2013-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.cloud.kubernetes.client.config;

import io.kubernetes.client.common.KubernetesObject;
import io.kubernetes.client.openapi.apis.CoreV1Api;

import org.springframework.cloud.kubernetes.client.config.reload.KubernetesClientEventBasedConfigMapChangeDetector;
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadProperties;
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigurationUpdateStrategy;
import org.springframework.core.env.ConfigurableEnvironment;

/**
* @author wind57
*/
public class VisibleKubernetesClientEventBasedConfigMapChangeDetector
extends KubernetesClientEventBasedConfigMapChangeDetector {

public VisibleKubernetesClientEventBasedConfigMapChangeDetector(CoreV1Api coreV1Api,
ConfigurableEnvironment environment, ConfigReloadProperties properties,
ConfigurationUpdateStrategy strategy, KubernetesClientConfigMapPropertySourceLocator propertySourceLocator,
KubernetesNamespaceProvider kubernetesNamespaceProvider) {
super(coreV1Api, environment, properties, strategy, propertySourceLocator, kubernetesNamespaceProvider);
}

public void onEvent(KubernetesObject kubernetesObject) {
super.onEvent(kubernetesObject);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* Copyright 2013-2022 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package org.springframework.cloud.kubernetes.client.config;

import io.kubernetes.client.common.KubernetesObject;
import io.kubernetes.client.openapi.apis.CoreV1Api;

import org.springframework.cloud.kubernetes.client.config.reload.KubernetesClientEventBasedSecretsChangeDetector;
import org.springframework.cloud.kubernetes.commons.KubernetesNamespaceProvider;
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigReloadProperties;
import org.springframework.cloud.kubernetes.commons.config.reload.ConfigurationUpdateStrategy;
import org.springframework.core.env.ConfigurableEnvironment;

/**
* @author wind57
*/
public class VisibleKubernetesClientEventBasedSecretsChangeDetector
extends KubernetesClientEventBasedSecretsChangeDetector {

public VisibleKubernetesClientEventBasedSecretsChangeDetector(CoreV1Api coreV1Api,
ConfigurableEnvironment environment, ConfigReloadProperties properties,
ConfigurationUpdateStrategy strategy, KubernetesClientSecretsPropertySourceLocator propertySourceLocator,
KubernetesNamespaceProvider kubernetesNamespaceProvider) {
super(coreV1Api, environment, properties, strategy, propertySourceLocator, kubernetesNamespaceProvider);
}

@Override
public void onEvent(KubernetesObject kubernetesObject) {
super.onEvent(kubernetesObject);
}

}
Loading
Loading