Skip to content

Commit

Permalink
Fix: global_conf not taking priority (#162)
Browse files Browse the repository at this point in the history
* Fix: global_conf not taking priority

* chore: move comments
  • Loading branch information
kiliantyler committed Feb 29, 2024
1 parent 449dacb commit 4ae531d
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions cmd/yamlfmt/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,19 +108,20 @@ func getConfigPath() (string, error) {
}

func getConfigPathFromFlag() (string, error) {
// If there is a path specified in the conf flag, that takes precedence
configPath := *flagConf
if configPath == "" {
logger.Debug(logger.DebugCodeConfig, "No config path specified in -conf")
return configPath, errNoConfFlag
}
// Then we check if we want the global config
// First check if the global configuration was explicitly requested as that takes precedence.
if *flagGlobalConf {
logger.Debug(logger.DebugCodeConfig, "Using -global_conf flag")
return getConfigPathFromXdgConfigHome()
}
logger.Debug(logger.DebugCodeConfig, "Using config path %s from -conf flag", configPath)
return configPath, validatePath(configPath)
// If the global config wasn't explicitly requested, check if there was a specific configuration path supplied.
configPath := *flagConf
if configPath != "" {
logger.Debug(logger.DebugCodeConfig, "Using config path %s from -conf flag", configPath)
return configPath, validatePath(configPath)
}

logger.Debug(logger.DebugCodeConfig, "No config path specified in -conf")
return configPath, errNoConfFlag
}

// This function searches up the directory tree until it finds
Expand Down

0 comments on commit 4ae531d

Please sign in to comment.