Skip to content

Commit

Permalink
Merge pull request #61 from foomo/viper-key-delimiter
Browse files Browse the repository at this point in the history
feat(config): set viper key delimiter
  • Loading branch information
franklinkim committed Apr 2, 2024
2 parents 1283e4c + e2ff375 commit 3a5a422
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions internal/config/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ func Load(l log.Logger) error {
var settings map[string]interface{}

if value := os.Getenv("POSH_ROOT_CONFIG_PATH"); value != "" {
c := viper.New()
c := viper.NewWithOptions(viper.KeyDelimiter("\\"))
c.AddConfigPath(value)
c.SetConfigType("yaml")
c.SetConfigName(".posh")
Expand All @@ -32,7 +32,7 @@ func Load(l log.Logger) error {
}

{ // load config
c := viper.New()
c := viper.NewWithOptions(viper.KeyDelimiter("\\"))
c.AddConfigPath(".")
c.SetConfigType("yaml")
c.SetConfigName(".posh")
Expand All @@ -48,7 +48,7 @@ func Load(l log.Logger) error {
}

{ // load override
c := viper.New()
c := viper.NewWithOptions(viper.KeyDelimiter("\\"))
c.AddConfigPath(".")
c.SetConfigType("yaml")
c.SetConfigName(".posh.override")
Expand All @@ -67,6 +67,8 @@ func Load(l log.Logger) error {
return errors.Wrap(err, "failed to merge config map")
}

// viper.Debug()

// validate version
if v := viper.GetString("version"); v != Version {
return fmt.Errorf("invalid config version: %s (%s)", v, Version)
Expand Down

0 comments on commit 3a5a422

Please sign in to comment.