Browse Source

CurrentUser only use global when needed

by needed: when host flag was supplied, matches that configured and a
user is set in config as well. they should be a pair.
pull/36/head
Rob Loranger 4 years ago
parent
commit
55dcf5e79c
No known key found for this signature in database GPG Key ID: D6F1633A4F0903B8
1 changed files with 8 additions and 1 deletions
  1. +8
    -1
      config/user.go

+ 8
- 1
config/user.go View File

@@ -147,10 +147,17 @@ func CurrentUser(c *cli.Context) (string, error) {
}
if cfg.Default.User == "" {
// Load app-level config
cfg, err = LoadConfig(UserDataDir(c.App.ExtraInfo()["configDir"]))
globalCFG, err := LoadConfig(UserDataDir(c.App.ExtraInfo()["configDir"]))
if err != nil {
return "", err
}
// only user global defaults when both are set and hosts match
if globalCFG.Default.User != "" &&
globalCFG.Default.Host != "" &&
c.GlobalIsSet("host") &&
globalCFG.Default.Host == c.GlobalString("host") {
cfg = globalCFG
}
}

// Use user flag value


Loading…
Cancel
Save