Allows disabling the SecretsPropertySourceLocator with a property.
fixes gh-125
This commit is contained in:
@@ -39,18 +39,19 @@ public class BootstrapConfiguration {
|
||||
@Import(KubernetesAutoConfiguration.class)
|
||||
@EnableConfigurationProperties({ ConfigMapConfigProperties.class,
|
||||
SecretsConfigProperties.class })
|
||||
@ConditionalOnProperty(name = "spring.cloud.kubernetes.config.enabled", matchIfMissing = true)
|
||||
protected static class KubernetesPropertySourceConfiguration {
|
||||
@Autowired
|
||||
private KubernetesClient client;
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(name = "spring.cloud.kubernetes.config.enabled", matchIfMissing = true)
|
||||
public ConfigMapPropertySourceLocator configMapPropertySourceLocator(
|
||||
ConfigMapConfigProperties properties) {
|
||||
return new ConfigMapPropertySourceLocator(client, properties);
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnProperty(name = "spring.cloud.kubernetes.secrets.enabled", matchIfMissing = true)
|
||||
public SecretsPropertySourceLocator secretsPropertySourceLocator(
|
||||
SecretsConfigProperties properties) {
|
||||
return new SecretsPropertySourceLocator(client, properties);
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
{"properties": [
|
||||
{
|
||||
"name": "spring.cloud.kubernetes.config.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable the ConfigMap property source locator.",
|
||||
"defaultValue": true
|
||||
},
|
||||
{
|
||||
"name": "spring.cloud.kubernetes.secrets.enabled",
|
||||
"type": "java.lang.Boolean",
|
||||
"description": "Enable the Secrets property source locator.",
|
||||
"defaultValue": true
|
||||
}
|
||||
]}
|
||||
|
||||
@@ -37,12 +37,12 @@ public class KubernetesConfigConfigurationTest {
|
||||
|
||||
@Test
|
||||
public void kubernetesWhenKubernetesConfigDisabled() throws Exception {
|
||||
setup("spring.cloud.kubernetes.config.enabled=false");
|
||||
setup("spring.cloud.kubernetes.config.enabled=false",
|
||||
"spring.cloud.kubernetes.secrets.enabled=false");
|
||||
assertFalse(context.containsBean("configMapPropertySourceLocator"));
|
||||
assertFalse(context.containsBean("secretsPropertySourceLocator"));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void kubernetesDefaultEnabled() throws Exception {
|
||||
setup("spring.cloud.kubernetes.enabled=true");
|
||||
|
||||
Reference in New Issue
Block a user