Skip to content

Commit

Permalink
fix: 🐛 omit expiration info if credentials can't expire
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesChung committed Apr 14, 2023
1 parent b4fd117 commit 2f8af66
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions pkg/util/credentials.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,10 +154,31 @@ func RemoveProfiles(profiles []string) error {
return nil
}

type credentials struct {
AccessKeyID string `json:"AccessKeyID"`
SecretAccessKey string `json:"SecretAccessKey"`
SessionToken string `json:"SessionToken"`
Source string `json:"Source"`
}

func StringifyCredentials(creds aws.Credentials) (string, error) {
b, err := json.Marshal(creds)
if err != nil {
return "", err
var b []byte
var err error
if creds.CanExpire {
b, err = json.Marshal(creds)
if err != nil {
return "", err
}
} else {
b, err = json.Marshal(credentials{
AccessKeyID: creds.AccessKeyID,
SecretAccessKey: creds.SecretAccessKey,
SessionToken: creds.SessionToken,
Source: creds.Source,
})
if err != nil {
return "", err
}
}
return string(b), nil
}
Expand Down

0 comments on commit 2f8af66

Please # to comment.