Cherry picking 35f4e1f
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -77,4 +77,4 @@ crashlytics-build.properties
|
||||
.settings/
|
||||
.project
|
||||
.classpath
|
||||
.factorypath
|
||||
.factorypath
|
||||
@@ -99,16 +99,18 @@ public class ConfigMapPropertySource extends MapPropertySource {
|
||||
}
|
||||
|
||||
if (environment != null) {
|
||||
for (String activeProfile:environment.getActiveProfiles()) {
|
||||
for (String activeProfile : environment.getActiveProfiles()) {
|
||||
|
||||
String mapNameWithProfile = name + "-" + activeProfile;
|
||||
|
||||
ConfigMap mapWithProfile = StringUtils.isEmpty(namespace)
|
||||
? client.configMaps().withName(mapNameWithProfile).get()
|
||||
: client.configMaps().inNamespace(namespace).withName(mapNameWithProfile).get();
|
||||
? client.configMaps().withName(mapNameWithProfile).get()
|
||||
: client.configMaps().inNamespace(namespace)
|
||||
.withName(mapNameWithProfile).get();
|
||||
|
||||
if (mapWithProfile != null) {
|
||||
result.putAll(processAllEntries(mapWithProfile.getData(), environment));
|
||||
result.putAll(
|
||||
processAllEntries(mapWithProfile.getData(), environment));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -125,7 +127,6 @@ public class ConfigMapPropertySource extends MapPropertySource {
|
||||
return new HashMap<>();
|
||||
}
|
||||
|
||||
|
||||
private static Map<String, String> processAllEntries(Map<String, String> input,
|
||||
Environment environment) {
|
||||
|
||||
|
||||
@@ -43,9 +43,9 @@ import static org.springframework.cloud.kubernetes.config.ConfigMapTestUtil.crea
|
||||
"spring.application.name=configmap-path-example",
|
||||
"spring.cloud.kubernetes.config.enableApi=false",
|
||||
"spring.cloud.kubernetes.config.paths="
|
||||
+ ConfigMapsFromFilePathsSpringBootTest.FIRST_FILE_NAME_FULL_PATH + ","
|
||||
+ ConfigMapsFromFilePathsSpringBootTest.SECOND_FILE_NAME_FULL_PATH })
|
||||
public class ConfigMapsFromFilePathsSpringBootTest {
|
||||
+ ConfigMapsFromFilePathsTests.FIRST_FILE_NAME_FULL_PATH + ","
|
||||
+ ConfigMapsFromFilePathsTests.SECOND_FILE_NAME_FULL_PATH })
|
||||
public class ConfigMapsFromFilePathsTests {
|
||||
|
||||
protected static final String FILES_ROOT_PATH = "/tmp/scktests";
|
||||
|
||||
@@ -42,11 +42,11 @@ import static org.springframework.cloud.kubernetes.config.ConfigMapTestUtil.read
|
||||
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = App.class, properties = {
|
||||
"spring.application.name=" + ConfigMapsMixedSpringBootTest.APPLICATION_NAME,
|
||||
"spring.application.name=" + ConfigMapsMixedTests.APPLICATION_NAME,
|
||||
"spring.cloud.kubernetes.config.enableApi=true",
|
||||
"spring.cloud.kubernetes.config.paths="
|
||||
+ ConfigMapsMixedSpringBootTest.FILE_NAME_FULL_PATH })
|
||||
public class ConfigMapsMixedSpringBootTest {
|
||||
+ ConfigMapsMixedTests.FILE_NAME_FULL_PATH })
|
||||
public class ConfigMapsMixedTests {
|
||||
|
||||
protected static final String FILES_ROOT_PATH = "/tmp/scktests";
|
||||
|
||||
@@ -45,7 +45,7 @@ import static org.assertj.core.api.Assertions.assertThat;
|
||||
"spring.application.name=configmap-example",
|
||||
"spring.cloud.kubernetes.reload.enabled=false" })
|
||||
@AutoConfigureWebTestClient
|
||||
public class ConfigMapsSpringBootTest {
|
||||
public class ConfigMapsTests {
|
||||
|
||||
private static final String APPLICATION_NAME = "configmap-example";
|
||||
|
||||
@@ -47,7 +47,7 @@ import static org.springframework.cloud.kubernetes.config.ConfigMapTestUtil.read
|
||||
"spring.cloud.kubernetes.reload.enabled=false" })
|
||||
@ActiveProfiles("development")
|
||||
@AutoConfigureWebTestClient
|
||||
public class ConfigMapsWithActiveProfilesNameSpringBootTest {
|
||||
public class ConfigMapsWithActiveProfilesNameTests {
|
||||
|
||||
private static final String APPLICATION_NAME = "configmap-with-active-profile-name-example";
|
||||
|
||||
@@ -46,7 +46,7 @@ import static org.springframework.cloud.kubernetes.config.ConfigMapTestUtil.read
|
||||
"spring.cloud.kubernetes.reload.enabled=false" })
|
||||
@ActiveProfiles({ "production", "us-east" })
|
||||
@AutoConfigureWebTestClient
|
||||
public class ConfigMapsWithProfileExpressionSpringBootTest {
|
||||
public class ConfigMapsWithProfileExpressionTests {
|
||||
|
||||
@ClassRule
|
||||
public static KubernetesServer server = new KubernetesServer();
|
||||
@@ -44,7 +44,7 @@ import static org.springframework.cloud.kubernetes.config.ConfigMapTestUtil.read
|
||||
"spring.application.name=configmap-with-profile-no-active-profiles-example",
|
||||
"spring.cloud.kubernetes.reload.enabled=false" })
|
||||
@AutoConfigureWebTestClient
|
||||
public class ConfigMapsWithProfilesNoActiveProfileSpringBootTest {
|
||||
public class ConfigMapsWithProfilesNoActiveProfileTests {
|
||||
|
||||
private static final String APPLICATION_NAME = "configmap-with-profile-no-active-profiles-example";
|
||||
|
||||
@@ -46,7 +46,7 @@ import static org.springframework.cloud.kubernetes.config.ConfigMapTestUtil.read
|
||||
"spring.cloud.kubernetes.reload.enabled=false" })
|
||||
@ActiveProfiles("development")
|
||||
@AutoConfigureWebTestClient
|
||||
public class ConfigMapsWithProfilesSpringBootTest {
|
||||
public class ConfigMapsWithProfilesTests {
|
||||
|
||||
private static final String APPLICATION_NAME = "configmap-with-profile-example";
|
||||
|
||||
@@ -43,7 +43,7 @@ import static org.springframework.cloud.kubernetes.config.ConfigMapTestUtil.read
|
||||
"spring.cloud.kubernetes.reload.enabled=false" })
|
||||
@ActiveProfiles("development")
|
||||
@AutoConfigureWebTestClient
|
||||
public class ConfigMapsWithoutProfilesSpringBootTest {
|
||||
public class ConfigMapsWithoutProfilesTests {
|
||||
|
||||
private static final String APPLICATION_NAME = "configmap-without-profile-example";
|
||||
|
||||
@@ -42,7 +42,7 @@ import org.springframework.test.web.reactive.server.WebTestClient;
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, classes = ExampleApp.class, properties = {
|
||||
"spring.cloud.bootstrap.name=multiplecms" })
|
||||
@AutoConfigureWebTestClient
|
||||
public class MultipleConfigMapsSpringBootTest {
|
||||
public class MultipleConfigMapsTests {
|
||||
|
||||
@ClassRule
|
||||
public static KubernetesServer server = new KubernetesServer();
|
||||
@@ -41,8 +41,7 @@ import org.springframework.integration.leader.event.LeaderEventPublisher;
|
||||
@Configuration
|
||||
@EnableConfigurationProperties(LeaderProperties.class)
|
||||
@ConditionalOnBean(KubernetesClient.class)
|
||||
@ConditionalOnProperty(value = "spring.cloud.kubernetes.leader.enabled",
|
||||
matchIfMissing = true)
|
||||
@ConditionalOnProperty(value = "spring.cloud.kubernetes.leader.enabled", matchIfMissing = true)
|
||||
public class LeaderAutoConfiguration {
|
||||
|
||||
@Bean
|
||||
|
||||
@@ -33,8 +33,7 @@ import static org.hamcrest.Matchers.containsString;
|
||||
@RunWith(SpringRunner.class)
|
||||
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT, properties = {
|
||||
// Make sure test passes without Kubernetes cluster
|
||||
"spring.cloud.kubernetes.leader.autoStartup=false"
|
||||
})
|
||||
"spring.cloud.kubernetes.leader.autoStartup=false" })
|
||||
public class LeaderAutoConfigurationTests {
|
||||
|
||||
@Value("${local.server.port}")
|
||||
|
||||
Reference in New Issue
Block a user