Skip to content

Conversation

@wind57
Copy link
Contributor

@wind57 wind57 commented Oct 5, 2025

No description provided.

@wind57 wind57 changed the title Drop enable-api property Drop enable-api property (3) Oct 5, 2025
Signed-off-by: wind57 <[email protected]>
* @author Ioannis Canellos
* @author Isik Erhan
*/
@ConfigurationProperties(ConfigMapConfigProperties.PREFIX)
Copy link
Contributor Author

@wind57 wind57 Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am proposing to drop : @DefaultValue("true") boolean enableApi.

At the moment, we have two flags :

spring.cloud.kubernetes.config.enabled
spring.cloud.kubernetes.config.enable-api

With spring.cloud.kubernetes.config.enabled we control path support and also the creation of specific beans. With spring.cloud.kubernetes.config.enable-api we control if we are allowed to read configmaps via the api.

Since we have dropped paths support, we can have a single flag now for controlling everything, so we can drop spring.cloud.kubernetes.config.enable-api


Since users are supposed to control everything in this regard with a single flag : spring.cloud.kubernetes.config.enabled, they should be OK simply because @DefaultValue("true") boolean enabled.

For secrets though, @DefaultValue("false") boolean enabled, so they will need to switch this flag to true. Thus this a breaking change and had to wait for its turn.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words the only option now is to use the API to load secrets and config maps since path support is no longer an option so the enabled flag covers all options, right?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did the secrets related tests work before with spring.cloud.kubernetes.secrets.enabled=false by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In other words the only option now is to use the API to load secrets and config maps since path support is no longer an option so the enabled flag covers all options, right?

correct.

How did the secrets related tests work before with spring.cloud.kubernetes.secrets.enabled=false by default?

Until now, we were not setting that property at all in tests, and :

@Target({ ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
@Inherited
@ConditionalOnProperty(value = "spring.cloud.kubernetes.secrets.enabled", matchIfMissing = true)
public @interface ConditionalOnKubernetesSecretsEnabled {

}

Notice that matchIfMissing = true. So there was no need to set anything.


I have changed that to matchIfMissing = false in this PR. My thought process was that enableApi = false until now, so if you wanted to use the API to read properties, you had to enable that. And since we control that now via enabled, you still have to enable it specifically.

The other idea of why I decided to have it as matchIfMissing = false is because we are not supposed to read secrets by default, that is why they are secrets after all; it was natural for me when I was thinking about it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah makes sense, path support for secrets was on by default but api support was not, right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

spot on!

});
}
Set<NormalizedSource> sources = new LinkedHashSet<>(this.properties.determineSources(environment));
LOG.debug("Config Map normalized sources : " + sources);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the only thing that changed here is dropping :

if (this.properties.enableApi()) { 

});
}
uniqueSources.forEach(secretSource -> {
MapPropertySource propertySource = getPropertySource(env, secretSource, properties.readType());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here, all I am doing is dropping the if in if (this.properties.enableApi()) {

wind57 added 11 commits October 6, 2025 11:05
Signed-off-by: wind57 <[email protected]>
Signed-off-by: wind57 <[email protected]>
Signed-off-by: wind57 <[email protected]>
Signed-off-by: wind57 <[email protected]>
Signed-off-by: wind57 <[email protected]>
Signed-off-by: wind57 <[email protected]>
Signed-off-by: wind57 <[email protected]>
Signed-off-by: wind57 <[email protected]>
Signed-off-by: wind57 <[email protected]>
Signed-off-by: wind57 <[email protected]>
Signed-off-by: wind57 <[email protected]>
@wind57 wind57 marked this pull request as ready for review October 6, 2025 14:22
@wind57
Copy link
Contributor Author

wind57 commented Oct 6, 2025

@ryanjbaxter this one is ready and touches a lot of files, but they all stem from some simple ones, that I commented in the PR

@ryanjbaxter ryanjbaxter added this to the 5.0.0-M4 milestone Oct 6, 2025
@ryanjbaxter ryanjbaxter merged commit 4fd9a85 into spring-cloud:main Oct 6, 2025
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

No open projects
Status: Done

Development

Successfully merging this pull request may close these issues.

3 participants