Don't mess with exiting .aws/credentials

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
This commit is contained in:
Nicolas De Loof 2020-11-16 14:50:39 +01:00
parent 0ae42dea04
commit cb808dec31
No known key found for this signature in database
GPG Key ID: 9858809D6F8F6E7E
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 {