Closed tomakehurst closed 11 years ago
Is this really needed or good hardcoded defaults are enough?
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.
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.
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.
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?
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
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.
@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.
Layering config files is also important for separating out sensitive values (e.g. mounting a Kubernetes
Secret
in addition mounting a KubernetesConfigMap
). 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
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?