Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document when environment variable property mapping applies #41877

Closed
michaelmcfadyensky opened this issue Aug 15, 2024 · 2 comments
Closed

Document when environment variable property mapping applies #41877

michaelmcfadyensky opened this issue Aug 15, 2024 · 2 comments
Assignees
Labels
type: documentation A documentation update
Milestone

Comments

@michaelmcfadyensky
Copy link

michaelmcfadyensky commented Aug 15, 2024

I have recently created a custom EnvironmentPostProcessor that added a new property source into the Environment. The property source I added was a SystemEnvironmentPropertySource. Everything was seemingly working as expected but some of the relaxed binding rules (described here) weren't being applied as expected.

After much debugging and searching I came across this stackoverflow answer that explains that to ensure the environment variable relaxed binding rules are applied correctly to custom property sources, the property source name has to end with "-systemEnvironment". I assumed (wrongly) that the binding rules would be determined by the property source type, not an arbitrary suffix on the name.

I did some further digging and could not finding any documentation explaining this. Could we add something into the docs to explain this specific use case?

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Aug 15, 2024
@wilkinsona
Copy link
Member

Thanks for the suggestion. Given that SystemEnvironmentPropertySource is documented as being a "specialization of MapPropertySource designed for use with system environment variables", I'd be interested to know what the use case is for a custom property source of this type. To avoid bloating the reference documentation too much, we have to make decisions about what we do and don't document and on the face off it, this seems like quite a niche need.

@wilkinsona wilkinsona added the status: waiting-for-feedback We need additional information before we can continue label Aug 15, 2024
@michaelmcfadyensky
Copy link
Author

I have environment variables that are encrypted. They typically contain passwords, secrets etc. I want to decrypt them in our spring boot apps in a common way before the Environment is fully loaded. As a result using an EnvironmentPostProcessor and adding a new property source in the environment was the direction that was taken to solve this.

Its similar to the suggestion here in the reference docs.

Since the source of the secrets are env vars, after decrypting them I create a new SystemEnvironmentPropertySource that contains the decrypted env vars and this is added to the property sources at a higher precedence than the default SystemEnvironmentPropertySource.

Its a replacement for a process that was previously done in bash, in my docker container before starting the spring boot app.

@spring-projects-issues spring-projects-issues added status: feedback-provided Feedback has been provided and removed status: waiting-for-feedback We need additional information before we can continue labels Aug 15, 2024
@wilkinsona wilkinsona changed the title Improve documentation on registering custom system environment property source via environment post processor Document when environment variable property mapping applies Aug 19, 2024
@wilkinsona wilkinsona added type: documentation A documentation update and removed status: waiting-for-triage An issue we've not yet triaged status: feedback-provided Feedback has been provided labels Aug 19, 2024
@wilkinsona wilkinsona added this to the 3.2.x milestone Aug 19, 2024
@wilkinsona wilkinsona self-assigned this Aug 19, 2024
@wilkinsona wilkinsona modified the milestones: 3.2.x, 3.2.9 Aug 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: documentation A documentation update
Projects
None yet
Development

No branches or pull requests

3 participants