Merge pull request #2818 from thaJeztah/prevent_panic

GetDefaultAuthConfig: fix potential panic due to unhandled error
This commit is contained in:
Tibor Vass 2020-10-29 14:43:01 -07:00 committed by GitHub
commit 1d20b15adc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 4 deletions

View File

@ -93,17 +93,18 @@ func GetDefaultAuthConfig(cli Cli, checkCredStore bool, serverAddress string, is
if !isDefaultRegistry {
serverAddress = registry.ConvertToHostname(serverAddress)
}
var authconfig configtypes.AuthConfig
var authconfig = configtypes.AuthConfig{}
var err error
if checkCredStore {
authconfig, err = cli.ConfigFile().GetAuthConfig(serverAddress)
} else {
authconfig = configtypes.AuthConfig{}
if err != nil {
return nil, err
}
}
authconfig.ServerAddress = serverAddress
authconfig.IdentityToken = ""
res := types.AuthConfig(authconfig)
return &res, err
return &res, nil
}
// ConfigureAuth handles prompting of user's username and password if needed