dropwizard / dropwizard

A damn simple library for building production-ready RESTful web services.
https://www.dropwizard.io
Apache License 2.0
8.46k stars 3.44k forks source link

Support multiple config files #125

Closed tomakehurst closed 11 years ago

tomakehurst commented 11 years ago

We'd find it really useful to be able to specify two config files at startup, one for defaults, one for environment-specific overrides.

Would you be interested in including this if we supply a patch?

andreisavu commented 11 years ago

Is this really needed or good hardcoded defaults are enough?

tomakehurst commented 11 years ago

Hardcoded defaults are pretty awkward for nested config classes e.g. LoggingConfiguration. Where these are immutable it's necessary to subclass them, providing copies of the private attributes with the defaults set. Even when they're mutable and you can default them from your config class's constructor, I suspect the evaluation order would be wrong.

codahale commented 11 years ago

This has come up on the mailing list. The combination of default values in the Configuration fields, configuration file, and command-line overrides is enough complexity.

frodereinertsen commented 10 years ago

A use case where this feature would make sense is when wanting to keep a config file out of version control, i.e. secrets.yml.

adamcath commented 9 years ago

I want this too. Trying to shove defaults into classes I didn't write sounds just too painful, and hard to read. Anyone had success hacking it in?

vvondra commented 8 years ago

A nice touch would be able to override config files, or even by default be able to import them from one another.

config.yml extended by config_prod.yml and config_staging.yml

sirianni commented 3 years ago

Layering config files is also important for separating out sensitive values (e.g. mounting a Kubernetes Secret in addition mounting a Kubernetes ConfigMap). Or using the Vault sidecar injector.

Almost all modern java microservice frameworks have this feature.

joschi commented 3 years ago

@sirianni You can override any setting in the configuration file with a system property or with environment variables.

See also: Using Secrets as environment variables and Dropwizard -> Configuration -> Environment variables.

vvondra commented 3 years ago

Layering config files is also important for separating out sensitive values (e.g. mounting a Kubernetes Secret in addition mounting a Kubernetes ConfigMap). Or using the Vault sidecar injector.

Almost all modern java microservice frameworks have this feature.

it's three years since I touched this, but we found a way to plug in this behaviour with our own code: https://github.com/vvondra/dropwizard-config-importable