Revert "chore: reorder config loading to load config, *then* fill in missing defaults (#185)"

This reverts commit 708cdd0ba8a1db4014898b67a3e6b380b9d94ea6.
This commit is contained in:
Matthew Penner 2025-08-27 14:46:09 -06:00
parent 695b2eaf86
commit 7bb7696307
No known key found for this signature in database

View File

@ -359,6 +359,12 @@ type Configuration struct {
// This function does not modify the currently stored global configuration. // This function does not modify the currently stored global configuration.
func NewAtPath(path string) (*Configuration, error) { func NewAtPath(path string) (*Configuration, error) {
var c Configuration 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. // Track the location where we created this configuration.
c.path = path c.path = path
return &c, nil return &c, nil
@ -570,13 +576,6 @@ func FromFile(path string) error {
return err 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
}
c.Token = Token{ c.Token = Token{
ID: os.Getenv("WINGS_TOKEN_ID"), ID: os.Getenv("WINGS_TOKEN_ID"),
Token: os.Getenv("WINGS_TOKEN"), Token: os.Getenv("WINGS_TOKEN"),