Fix ignored overridden flag in user config (#1059)

* Fix ignored overridden flag in user config

* rename variable
This commit is contained in:
Michal Niewrzal 2019-01-15 16:03:24 -05:00 committed by GitHub
parent 728908fac4
commit 01e4811a6f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -78,15 +78,20 @@ func saveConfig(flagset *pflag.FlagSet, outfile string, overrides map[string]int
if readBoolAnnotation(f, "setup") {
continue
}
if !saveAllDefaults && !readBoolAnnotation(f, "user") && !f.Changed {
var overriddenValue interface{}
var overrideExist bool
if overrides != nil {
overriddenValue, overrideExist = overrides[k]
}
if !saveAllDefaults && !readBoolAnnotation(f, "user") && !f.Changed && !overrideExist {
continue
}
value := f.Value.String()
if overrides != nil {
if v, ok := overrides[k]; ok {
value = fmt.Sprintf("%v", v)
}
if overriddenValue != nil {
value = fmt.Sprintf("%v", overriddenValue)
}
if f.Usage != "" {
fmt.Fprintf(w, "# %s\n", f.Usage)