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

Loading arrays from the Environment #402

Open
Perondas opened this issue Feb 21, 2024 · 1 comment
Open

Loading arrays from the Environment #402

Perondas opened this issue Feb 21, 2024 · 1 comment

Comments

@Perondas
Copy link

I am trying to load an arrayof strings from the environemnt. I cannot however figure out the correct syntax for it.

For example:

serversettings.cors = ["http://localhost","https://some.domain"]

with

 EnvironmentVariablesPropertySource(useUnderscoresAsSeparator = true, allowUppercaseNames = true)

When I supply the environment variable:

SERVERSETTINGS__CORS='["http://localhost","https://some.domain"]'

It passes the entire string with the square brackets into the first position of the list.

Does Hoplite support some syntax for passing arrays?

@rocketraman
Copy link
Contributor

rocketraman commented Mar 18, 2024

See also for reference the way Spring does it:

Environment variables can also be used when binding to object lists. To bind to a List, the element number should be surrounded with underscores in the variable name.

For example, the configuration property my.service[0].other would use an environment variable named MY_SERVICE_0_OTHER.

That being said, I think that is a less well known feature than Spring's basic env var mapping, so Hoplite could reasonably use a different approach.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants