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 dee7cd4
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 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 Down

0 comments on commit dee7cd4

Please sign in to comment.