Reorder config loading to load config and *then* fill in missing defaults
This commit is contained in:
parent
1d5090957b
commit
b279bf1f88
|
@ -332,12 +332,6 @@ type Configuration struct {
|
|||
// This function does not modify the currently stored global configuration.
|
||||
func NewAtPath(path string) (*Configuration, error) {
|
||||
var c Configuration
|
||||
// Configures the default values for many of the configuration options present
|
||||
// in the structs. Values set in the configuration file take priority over the
|
||||
// default values.
|
||||
if err := defaults.Set(&c); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Track the location where we created this configuration.
|
||||
c.path = path
|
||||
return &c, nil
|
||||
|
@ -513,6 +507,13 @@ func FromFile(path string) error {
|
|||
return err
|
||||
}
|
||||
|
||||
// Configures the default values for many of the configuration options present
|
||||
// in the structs. Values set in the configuration file will not be overridden by the
|
||||
// default values.
|
||||
if err := defaults.Set(c); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// Store this configuration in the global state.
|
||||
Set(c)
|
||||
return nil
|
||||
|
|
Loading…
Reference in New Issue
Block a user