Merge pull request #915 from docker/aws_creds

Don't mess with exiting .aws/credentials
This commit is contained in:
Nicolas De loof 2020-11-16 17:34:50 +01:00 committed by GitHub
commit 564b5fb793
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 3 deletions

View File

@ -199,8 +199,15 @@ func (h contextCreateAWSHelper) saveCredentials(profile string, accessKeyID stri
return err
}
credIni := ini.Empty()
section, err := credIni.NewSection(profile)
credentials, err := ini.Load(file)
if err != nil {
if !os.IsNotExist(err) {
return err
}
credentials = ini.Empty()
}
section, err := credentials.NewSection(profile)
if err != nil {
return err
}
@ -212,7 +219,7 @@ func (h contextCreateAWSHelper) saveCredentials(profile string, accessKeyID stri
if err != nil {
return err
}
return credIni.SaveTo(file)
return credentials.SaveTo(file)
}
func (h contextCreateAWSHelper) saveRegion(profile, region string) error {