Skip to content

Commit

Permalink
Merge pull request #4451 from vvoland/fix-issue-4414-Danial-Gharib-23
Browse files Browse the repository at this point in the history
[23.0 backport] configfile: Initialize nil AuthConfigs
  • Loading branch information
thaJeztah authored Jul 19, 2023
2 parents 006486f + b0dca39 commit 67df4e8
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 @@ -95,6 +95,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 67df4e8

Please sign in to comment.