|
21 | 21 |
|
22 | 22 | import io.kubernetes.client.openapi.apis.CoreV1Api; |
23 | 23 |
|
| 24 | +import org.springframework.beans.factory.ObjectProvider; |
24 | 25 | import org.springframework.boot.autoconfigure.AutoConfigureAfter; |
25 | 26 | import org.springframework.boot.autoconfigure.AutoConfigureBefore; |
26 | 27 | import org.springframework.boot.autoconfigure.condition.ConditionalOnCloudPlatform; |
| 28 | +import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean; |
27 | 29 | import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; |
28 | 30 | import org.springframework.boot.cloud.CloudPlatform; |
29 | 31 | import org.springframework.boot.context.properties.EnableConfigurationProperties; |
|
57 | 59 | @EnableConfigurationProperties(KubernetesConfigServerProperties.class) |
58 | 60 | public class KubernetesConfigServerAutoConfiguration { |
59 | 61 |
|
60 | | - @Configuration(proxyBeanMethods = false) |
61 | | - static class KubernetesFactoryConfig { |
62 | | - |
63 | | - @Bean |
64 | | - public KubernetesEnvironmentRepositoryFactory kubernetesEnvironmentRepositoryFactory( |
65 | | - KubernetesEnvironmentRepository kubernetesEnvironmentRepository) { |
66 | | - return new KubernetesEnvironmentRepositoryFactory(kubernetesEnvironmentRepository); |
67 | | - } |
| 62 | + @Bean |
| 63 | + @ConditionalOnMissingBean |
| 64 | + public KubernetesEnvironmentRepositoryFactory kubernetesEnvironmentRepositoryFactory( |
| 65 | + ObjectProvider<KubernetesEnvironmentRepository> kubernetesEnvironmentRepositoryProvider) { |
| 66 | + return new KubernetesEnvironmentRepositoryFactory(kubernetesEnvironmentRepositoryProvider); |
68 | 67 | } |
69 | 68 |
|
70 | 69 | @Bean |
71 | 70 | @Profile("kubernetes") |
| 71 | + @ConditionalOnMissingBean |
72 | 72 | public EnvironmentRepository kubernetesEnvironmentRepository(CoreV1Api coreV1Api, |
73 | 73 | List<KubernetesPropertySourceSupplier> kubernetesPropertySourceSuppliers, |
74 | 74 | KubernetesNamespaceProvider kubernetesNamespaceProvider) { |
75 | | - System.out.println("Creating KubernetesEnvironmentRepository bean..."); |
76 | 75 | return new KubernetesEnvironmentRepository(coreV1Api, kubernetesPropertySourceSuppliers, |
77 | 76 | kubernetesNamespaceProvider.getNamespace()); |
78 | 77 | } |
|
0 commit comments