Skip to content

Commit

Permalink
Merge pull request #4452 from vvoland/fix-issue-4414-Danial-Gharib-2010
Browse files Browse the repository at this point in the history
[20.10 backport] configfile: Initialize nil AuthConfigs
  • Loading branch information
thaJeztah authored Jul 19, 2023
2 parents 4960d5e + 3fa3542 commit 4b0940b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
3 changes: 3 additions & 0 deletions cli/config/configfile/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ func (configFile *ConfigFile) ContainsAuth() bool {

// GetAuthConfigs returns the mapping of repo to auth configuration
func (configFile *ConfigFile) GetAuthConfigs() map[string]types.AuthConfig {
if configFile.AuthConfigs == nil {
configFile.AuthConfigs = make(map[string]types.AuthConfig)
}
return configFile.AuthConfigs
}

Expand Down
3 changes: 2 additions & 1 deletion cli/config/credentials/file_store.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ func (c *fileStore) GetAll() (map[string]types.AuthConfig, error) {

// Store saves the given credentials in the file store.
func (c *fileStore) Store(authConfig types.AuthConfig) error {
c.file.GetAuthConfigs()[authConfig.ServerAddress] = authConfig
authConfigs := c.file.GetAuthConfigs()
authConfigs[authConfig.ServerAddress] = authConfig
return c.file.Save()
}

Expand Down

0 comments on commit 4b0940b

Please sign in to comment.