Skip to content

Commit

Permalink
align annotations (#1793)
Browse files Browse the repository at this point in the history
  • Loading branch information
wind57 authored Nov 14, 2024
1 parent 18f9c41 commit d33764d
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import org.springframework.cloud.kubernetes.commons.config.ConfigMapConfigProperties;
import org.springframework.cloud.kubernetes.commons.config.KubernetesBootstrapConfiguration;
import org.springframework.cloud.kubernetes.commons.config.SecretsConfigProperties;
import org.springframework.cloud.util.ConditionalOnBootstrapEnabled;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
Expand All @@ -41,6 +42,7 @@
@Configuration(proxyBeanMethods = false)
@AutoConfigureAfter(KubernetesBootstrapConfiguration.class)
@Import({ KubernetesCommonsAutoConfiguration.class, KubernetesClientAutoConfiguration.class })
@ConditionalOnBootstrapEnabled
@ConditionalOnCloudPlatform(CloudPlatform.KUBERNETES)
public class KubernetesClientBootstrapConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ void kubernetesReloadEnabledButSecretAndConfigDisabled() {
*/
@Test
void reloadEventEnabledMonitoringConfigMapsEnabledByDefault() {
setup("spring.cloud.kubernetes.reload.enabled=true", "spring.main.cloud-platform=KUBERNETES");
setup("spring.cloud.bootstrap.enabled=true", "spring.cloud.kubernetes.reload.enabled=true",
"spring.main.cloud-platform=KUBERNETES");
Map<String, ConfigurationChangeDetector> map = context.getBeansOfType(ConfigurationChangeDetector.class);
Assertions.assertEquals(map.size(), 1);
Assertions.assertTrue(map.values()
Expand All @@ -197,8 +198,8 @@ void reloadEventEnabledMonitoringConfigMapsEnabledByDefault() {
*/
@Test
void reloadEventEnabledMonitoringConfigMapsEnabled() {
setup("spring.cloud.kubernetes.reload.enabled=true", "spring.cloud.kubernetes.reload.mode=event",
"spring.main.cloud-platform=KUBERNETES");
setup("spring.cloud.bootstrap.enabled=true", "spring.cloud.kubernetes.reload.enabled=true",
"spring.cloud.kubernetes.reload.mode=event", "spring.main.cloud-platform=KUBERNETES");
Map<String, ConfigurationChangeDetector> map = context.getBeansOfType(ConfigurationChangeDetector.class);
Assertions.assertEquals(map.size(), 1);
Assertions.assertTrue(map.values()
Expand Down Expand Up @@ -259,8 +260,8 @@ void reloadPollingEnabledMonitoringConfigMapsDisabledMonitoringSecretsDisabled()
*/
@Test
void reloadPollingEnabledMonitoringConfigMapsEnabled() {
setup("spring.cloud.kubernetes.reload.enabled=true", "spring.cloud.kubernetes.reload.mode=polling",
"spring.main.cloud-platform=KUBERNETES");
setup("spring.cloud.bootstrap.enabled=true", "spring.cloud.kubernetes.reload.enabled=true",
"spring.cloud.kubernetes.reload.mode=polling", "spring.main.cloud-platform=KUBERNETES");
Map<String, ConfigurationChangeDetector> map = context.getBeansOfType(ConfigurationChangeDetector.class);
Assertions.assertEquals(map.size(), 1);
Assertions.assertTrue(
Expand All @@ -281,8 +282,8 @@ void reloadPollingEnabledMonitoringConfigMapsEnabled() {
*/
@Test
void reloadEventEnabledMonitoringConfigMapsDisabledMonitoringSecretsEnabled() {
setup("spring.cloud.kubernetes.reload.enabled=true", "spring.main.cloud-platform=KUBERNETES",
"spring.cloud.kubernetes.reload.monitoring-secrets=true",
setup("spring.cloud.bootstrap.enabled=true", "spring.cloud.kubernetes.reload.enabled=true",
"spring.main.cloud-platform=KUBERNETES", "spring.cloud.kubernetes.reload.monitoring-secrets=true",
"spring.cloud.kubernetes.reload.monitoring-configMaps=false",
"spring.cloud.kubernetes.reload.mode=event");
Map<String, ConfigurationChangeDetector> map = context.getBeansOfType(ConfigurationChangeDetector.class);
Expand All @@ -308,8 +309,8 @@ void reloadEventEnabledMonitoringConfigMapsDisabledMonitoringSecretsEnabled() {
*/
@Test
void reloadPollingEnabledMonitoringConfigMapsDisabledMonitoringSecretsEnabled() {
setup("spring.cloud.kubernetes.reload.enabled=true", "spring.main.cloud-platform=KUBERNETES",
"spring.cloud.kubernetes.reload.monitoring-secrets=true",
setup("spring.cloud.bootstrap.enabled=true", "spring.cloud.kubernetes.reload.enabled=true",
"spring.main.cloud-platform=KUBERNETES", "spring.cloud.kubernetes.reload.monitoring-secrets=true",
"spring.cloud.kubernetes.reload.monitoring-configMaps=false",
"spring.cloud.kubernetes.reload.mode=polling");
Map<String, ConfigurationChangeDetector> map = context.getBeansOfType(ConfigurationChangeDetector.class);
Expand All @@ -332,8 +333,8 @@ void reloadPollingEnabledMonitoringConfigMapsDisabledMonitoringSecretsEnabled()
*/
@Test
void reloadEventEnabledMonitoringConfigMapsEnabledMonitoringSecretsEnabled() {
setup("spring.cloud.kubernetes.reload.enabled=true", "spring.main.cloud-platform=KUBERNETES",
"spring.cloud.kubernetes.reload.monitoring-secrets=true",
setup("spring.cloud.bootstrap.enabled=true", "spring.cloud.kubernetes.reload.enabled=true",
"spring.main.cloud-platform=KUBERNETES", "spring.cloud.kubernetes.reload.monitoring-secrets=true",
"spring.cloud.kubernetes.reload.monitoring-configMaps=true",
"spring.cloud.kubernetes.reload.mode=event");
Map<String, ConfigurationChangeDetector> map = context.getBeansOfType(ConfigurationChangeDetector.class);
Expand All @@ -360,8 +361,8 @@ void reloadEventEnabledMonitoringConfigMapsEnabledMonitoringSecretsEnabled() {
*/
@Test
void reloadPollingEnabledMonitoringConfigMapsEnabledMonitoringSecretsEnabled() {
setup("spring.cloud.kubernetes.reload.enabled=true", "spring.main.cloud-platform=KUBERNETES",
"spring.cloud.kubernetes.reload.monitoring-secrets=true",
setup("spring.cloud.bootstrap.enabled=true", "spring.cloud.kubernetes.reload.enabled=true",
"spring.main.cloud-platform=KUBERNETES", "spring.cloud.kubernetes.reload.monitoring-secrets=true",
"spring.cloud.kubernetes.reload.monitoring-configMaps=true",
"spring.cloud.kubernetes.reload.mode=polling");
Map<String, ConfigurationChangeDetector> map = context.getBeansOfType(ConfigurationChangeDetector.class);
Expand Down Expand Up @@ -430,8 +431,9 @@ void reloadPollingEnabledMonitorConfigMapsDisabledMonitoringSecretsDisabled() {
*/
@Test
void reloadEventEnabledMonitoringConfigMapsEnabledMonitoringSecretsDisabled() {
setup("spring.cloud.kubernetes.reload.enabled=true", "spring.cloud.kubernetes.reload.mode=event",
"spring.main.cloud-platform=KUBERNETES", "spring.cloud.kubernetes.reload.monitoring-configMaps=true",
setup("spring.cloud.bootstrap.enabled=true", "spring.cloud.kubernetes.reload.enabled=true",
"spring.cloud.kubernetes.reload.mode=event", "spring.main.cloud-platform=KUBERNETES",
"spring.cloud.kubernetes.reload.monitoring-configMaps=true",
"spring.cloud.kubernetes.reload.monitoring-secrets=false");
Map<String, ConfigurationChangeDetector> map = context.getBeansOfType(ConfigurationChangeDetector.class);
Assertions.assertEquals(map.size(), 1);
Expand All @@ -456,8 +458,9 @@ void reloadEventEnabledMonitoringConfigMapsEnabledMonitoringSecretsDisabled() {
*/
@Test
void reloadPollingEnabledMonitoringConfigMapsEnabledMonitoringSecretsDisabled() {
setup("spring.cloud.kubernetes.reload.enabled=true", "spring.cloud.kubernetes.reload.mode=polling",
"spring.main.cloud-platform=KUBERNETES", "spring.cloud.kubernetes.reload.monitoring-configMaps=true",
setup("spring.cloud.bootstrap.enabled=true", "spring.cloud.kubernetes.reload.enabled=true",
"spring.cloud.kubernetes.reload.mode=polling", "spring.main.cloud-platform=KUBERNETES",
"spring.cloud.kubernetes.reload.monitoring-configMaps=true",
"spring.cloud.kubernetes.reload.monitoring-secrets=false");
Map<String, ConfigurationChangeDetector> map = context.getBeansOfType(ConfigurationChangeDetector.class);
Assertions.assertEquals(map.size(), 1);
Expand All @@ -472,21 +475,23 @@ void reloadPollingEnabledMonitoringConfigMapsEnabledMonitoringSecretsDisabled()

@Test
void kubernetesConfigAndSecretEnabledByDefault() {
setup("spring.main.cloud-platform=KUBERNETES");
setup("spring.cloud.bootstrap.enabled=true", "spring.main.cloud-platform=KUBERNETES");
assertThat(context.containsBean("configMapPropertySourceLocator")).isTrue();
assertThat(context.containsBean("secretsPropertySourceLocator")).isTrue();
}

@Test
void kubernetesConfigEnabledButSecretDisabled() {
setup("spring.cloud.kubernetes.secrets.enabled=false", "spring.main.cloud-platform=KUBERNETES");
setup("spring.cloud.bootstrap.enabled=true", "spring.cloud.kubernetes.secrets.enabled=false",
"spring.main.cloud-platform=KUBERNETES");
assertThat(context.containsBean("configMapPropertySourceLocator")).isTrue();
assertThat(context.containsBean("secretsPropertySourceLocator")).isFalse();
}

@Test
void kubernetesSecretsEnabledButConfigDisabled() {
setup("spring.cloud.kubernetes.config.enabled=false", "spring.main.cloud-platform=KUBERNETES");
setup("spring.cloud.bootstrap.enabled=true", "spring.cloud.kubernetes.config.enabled=false",
"spring.main.cloud-platform=KUBERNETES");
assertThat(context.containsBean("configMapPropertySourceLocator")).isFalse();
assertThat(context.containsBean("secretsPropertySourceLocator")).isTrue();
}
Expand Down

0 comments on commit d33764d

Please sign in to comment.