Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
davidleerh committed Jun 27, 2024
1 parent 8ad39f0 commit 366b5f3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
9 changes: 7 additions & 2 deletions pkg/aws/validations/iam_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,12 @@ import (
cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
)

const (
duplicateIamRoleArnErrorMsg = "ROSA IAM roles must have unique ARNs " +
"and should not be shared with other IAM roles within the same cluster. " +
"Duplicated role arn: %s"
)

func GetRoleName(prefix string, role string) string {
name := fmt.Sprintf("%s-%s-Role", prefix, role)
if len(name) > MaxAwsRoleLength {
Expand Down Expand Up @@ -75,8 +81,7 @@ func IamRoleArnsValidator(cluster *cmv1.Cluster) error {

for _, arn := range clusterIamRoles {
if _, exist := validatingMap[arn]; exist {
return fmt.Errorf("ROSA IAM roles requires unique ARNs and should not be shared by other cluster IAM roles. "+
"Duplicated role arn: %s", arn)
return fmt.Errorf(duplicateIamRoleArnErrorMsg, arn)
}
validatingMap[arn] = struct{}{}
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/aws/validations/iam_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,8 +164,7 @@ var _ = Describe("AWS iamtypes Functions", func() {
err = IamRoleArnsValidator(fakeCluster)
Expect(err).To(HaveOccurred())
Expect(err.Error()).To(Equal(
fmt.Sprintf("ROSA IAM roles requires unique ARNs and should not be shared by other cluster IAM roles. "+
"Duplicated role arn: %s", "installer"),
fmt.Sprintf(duplicateIamRoleArnErrorMsg, "installer"),
))
})

Expand Down

0 comments on commit 366b5f3

Please sign in to comment.