mirror of https://github.com/docker/docs.git
Copy authConfigs on save so data is not modified
SaveConfig sets the Username and Password to an empty string on save. A copy of the authConfigs need to be made so that the in memory data is not modified.
This commit is contained in:
parent
6ae3305040
commit
9332c00ca5
15
auth/auth.go
15
auth/auth.go
|
@ -116,14 +116,19 @@ func SaveConfig(configFile *ConfigFile) error {
|
||||||
os.Remove(confFile)
|
os.Remove(confFile)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
configs := make(map[string]AuthConfig, len(configFile.Configs))
|
||||||
for k, authConfig := range configFile.Configs {
|
for k, authConfig := range configFile.Configs {
|
||||||
authConfig.Auth = encodeAuth(&authConfig)
|
authCopy := authConfig
|
||||||
authConfig.Username = ""
|
|
||||||
authConfig.Password = ""
|
authCopy.Auth = encodeAuth(&authCopy)
|
||||||
configFile.Configs[k] = authConfig
|
authCopy.Username = ""
|
||||||
|
authCopy.Password = ""
|
||||||
|
|
||||||
|
configs[k] = authCopy
|
||||||
}
|
}
|
||||||
|
|
||||||
b, err := json.Marshal(configFile.Configs)
|
b, err := json.Marshal(configs)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue