This PR corrects 2 issues:
1) Slices (including those with embedded structs/more slices) are now properly summarized in valid YAML such that a user is able to copy/paste the entire configuration to a file and edit from there
2) Slices were being modified instead of using the values from a configuration file
Make a config file with a different set of excludes:
Exclude:
- set
- value
Then load this configuration file into the struct with defaults:
c := NewConfig()
fangs.Load(..., c)
... Viper will modify entries instead of using the config file as the source of truth: c.Exclude contains: "set", "value", "values", including a mix of defaults if the default list is longer than the config provided one.
Example (trimmed) before/after from Chronicle:
Before:
# output format to use: [md json] (env: CHRONICLE_OUTPUT)
output: 'md'
github:
# (env: CHRONICLE_GITHUB_HOST)
host: 'github.com'
# (env: CHRONICLE_GITHUB_EXCLUDE_LABELS)
exclude-labels: [duplicate question invalid wontfix wont-fix release-ignore changelog-ignore ignore]
# (env: CHRONICLE_GITHUB_CONSIDER_PR_MERGE_COMMITS)
consider-pr-merge-commits: true
# (env: CHRONICLE_GITHUB_CHANGES)
changes: [{security-fixes Security Fixes patch [security vulnerability]} {added-feature Added Features minor [enhancement feature minor]} {bug-fix Bug Fixes patch [bug fix bug-fix patch]} {breaking-feature Breaking Changes major [breaking backwards-incompatible breaking-change breaking-feature major]} {removed-feature Removed Features major [removed]} {deprecated-feature Deprecated Features minor [deprecated]} {unknown Additional Changes []}]
This PR corrects 2 issues: 1) Slices (including those with embedded structs/more slices) are now properly summarized in valid YAML such that a user is able to copy/paste the entire configuration to a file and edit from there 2) Slices were being modified instead of using the values from a configuration file
An example of the second issue is:
Make a config file with a different set of excludes:
Then load this configuration file into the struct with defaults:
... Viper will modify entries instead of using the config file as the source of truth:
c.Exclude
contains:"set", "value", "values"
, including a mix of defaults if the default list is longer than the config provided one.Example (trimmed) before/after from Chronicle:
Before:
After: