Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: global_conf not taking priority #162

Merged
merged 2 commits into from
Feb 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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