Support arbitrary sources in Config.load_files and Config.load_and_set_settings #315
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Config.load_and_set_settings
is the most convenient interface for initializing theSettings
object with a bunch of configuration sources. However, one problem is that it only allows paths to YAML files. This means that if the user wants to use an explicitConfig::Sources::HashSource
or aConfig::Sources::EnvSource
such as for AWS Secrets Manager, they have to calladd_source!
andreload!
separately.This is especially cumbersome if the user is using a validation contract and the settings aren't yet valid until adding the non-YAML sources. It's possible to work around this problem by setting the
validation_contact
after adding all sources:That's clunky. It'd be easier if the user could just specify the non-YAML sources up front.
This change makes this possible. There are some breaking changes in a few edge cases, but I expect that most applications will be able to upgrade without modification.