Skip to content

Commit

Permalink
chore: reorder config loading to load config, *then* fill in missing …
Browse files Browse the repository at this point in the history
…defaults (#185)
  • Loading branch information
danny6167 committed Aug 29, 2024
1 parent adb2b26 commit 708cdd0
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -351,12 +351,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
Expand Down Expand Up @@ -563,6 +557,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
Expand Down

0 comments on commit 708cdd0

Please sign in to comment.