godzsa
godzsa

Reputation: 2395

Dropwizard configuration with list of strings in environment variable with default fallback?

Dropwizard takes .yml configurations which of course allow lists. It also has the ${FOO:-bar} syntax which allows reading environment variables with default fallback.

Is there a way to read lists of strings from an env variable and parse automatically with Dropwizard or do I have to do it manually? What is the syntax to have a default fallback list if this exists? I could not find this in their documentation.

Upvotes: 1

Views: 1222

Answers (1)

godzsa
godzsa

Reputation: 2395

Thic can be achived by using a json format in the default parameter:

supported_locales: ${SUPPORTED_LOCALES:-[en,da_DK,pt_BR,es]}

This will make a config parameter called supported_locales which takes a SUPPORTED_LOCALES env variable (json array of strings format), and defaults to the array provided after the - character in this case [en,da_DK,pt_BR,es]

Upvotes: 3

Related Questions