Skip to content

Commit

Permalink
refactor: code reviews
Browse files Browse the repository at this point in the history
  • Loading branch information
Ayushi Sharma committed Dec 24, 2024
1 parent 0ffbd98 commit d8d1548
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions plugins/providers/oss/provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -468,26 +468,26 @@ func getPrincipalFromAccountID(accountID, accountType string) (string, error) {
if accountType == AccountTypeRAMUser {
accountIDParts := strings.Split(accountID, "$")
if len(accountIDParts) < 2 {
return "", fmt.Errorf("invalid accountID format")
return "", fmt.Errorf("invalid accountID format: %q", accountID)
}

subParts := strings.Split(accountIDParts[1], ":")
if len(subParts) < 2 {
return "", fmt.Errorf("invalid accountID format")
return "", fmt.Errorf("invalid accountID format: %q", accountID)
}

return subParts[1], nil
} else if accountType == AccountTypeRAMRole {

accountIDParts := strings.Split(accountID, ":")
if len(accountIDParts) < 5 {
return "", fmt.Errorf("invalid accountID format")
return "", fmt.Errorf("invalid accountID format: %q", accountID)
}

mainAccountID := accountIDParts[3]
roleNameParts := strings.Split(accountIDParts[4], "/")
if len(roleNameParts) < 2 {
return "", fmt.Errorf("invalid accountID format")
return "", fmt.Errorf("invalid accountID format: %q", accountID)
}

roleName := roleNameParts[1]
Expand All @@ -496,7 +496,7 @@ func getPrincipalFromAccountID(accountID, accountType string) (string, error) {
return fmt.Sprintf("arn:sts::%s:assumed-role/%s/*", mainAccountID, roleName), nil
}

return "", fmt.Errorf("invalid account type")
return "", fmt.Errorf("invalid account type: %q", accountType)

}

Expand Down

0 comments on commit d8d1548

Please sign in to comment.