Merge branch '2.0.x'
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2013-2019 the original author or authors.
|
||||
* Copyright 2013-2021 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.
|
||||
@@ -22,7 +22,6 @@ import java.util.Map;
|
||||
import io.fabric8.kubernetes.api.model.ConfigMapBuilder;
|
||||
import io.fabric8.kubernetes.api.model.SecretBuilder;
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
import io.fabric8.kubernetes.client.DefaultKubernetesClient;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import io.fabric8.kubernetes.client.server.mock.EnableKubernetesMockClient;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
@@ -52,13 +51,6 @@ public class CoreTest {
|
||||
@Autowired
|
||||
private Config config;
|
||||
|
||||
// not a fan of changing the type from KubernetesClient, but because of:
|
||||
// https://github.com/fabric8io/kubernetes-client/issues/3145
|
||||
// there is no way to do it otherwise at this time. When that is fixed, I will fix
|
||||
// this also
|
||||
@Autowired
|
||||
private DefaultKubernetesClient client;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUpBeforeClass() {
|
||||
|
||||
@@ -89,12 +81,6 @@ public class CoreTest {
|
||||
assertThat(config.isTrustCerts()).isTrue();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void kubernetesClientBeanShouldBeConfigurableViaSystemProperties() {
|
||||
assertThat(client).isNotNull();
|
||||
assertThat(client.getConfiguration().getMasterUrl()).isEqualTo(mockClient.getConfiguration().getMasterUrl());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void propertiesShouldBeReadFromConfigMap() {
|
||||
assertThat(environment.getProperty("spring.kubernetes.test.value")).isEqualTo("value1");
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright 2013-2021 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.fabric8.config;
|
||||
|
||||
import io.fabric8.kubernetes.client.Config;
|
||||
import io.fabric8.kubernetes.client.KubernetesClient;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.test.context.SpringBootTest;
|
||||
import org.springframework.test.context.junit.jupiter.SpringExtension;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
@ExtendWith(SpringExtension.class)
|
||||
@SpringBootTest(classes = TestApplication.class,
|
||||
properties = { "spring.application.name=testapp", "spring.cloud.kubernetes.client.namespace=testns",
|
||||
"spring.cloud.kubernetes.client.trustCerts=true", "spring.cloud.kubernetes.config.namespace=testns",
|
||||
"spring.cloud.kubernetes.secrets.enableApi=true" })
|
||||
public class CoreTestClientViaSystemProperties {
|
||||
|
||||
@Autowired
|
||||
private KubernetesClient client;
|
||||
|
||||
@BeforeAll
|
||||
public static void setUpBeforeClass() {
|
||||
System.setProperty(Config.KUBERNETES_MASTER_SYSTEM_PROPERTY, "masterURL");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void kubernetesClientBeanShouldBeConfigurableViaSystemProperties() {
|
||||
assertThat(client).isNotNull();
|
||||
assertThat(client.getConfiguration().getMasterUrl()).isEqualTo("http://masterURL/");
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user