Skip to content

Commit

Permalink
OCM-0000 | feat: removing unecessary function
Browse files Browse the repository at this point in the history
  • Loading branch information
den-rgb committed Oct 19, 2023
1 parent d0be7f2 commit f330f50
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 77 deletions.
27 changes: 0 additions & 27 deletions pkg/aws/validations/iam_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"fmt"
"github.com/aws/aws-sdk-go/service/iam"
"github.com/aws/aws-sdk-go/aws"
semver "github.com/hashicorp/go-version"
"github.com/openshift-online/ocm-common/pkg"
)

Expand All @@ -26,32 +25,6 @@ func IsManagedRole(roleTags []*iam.Tag) bool {
return false
}

func HasCompatibleVersionTags(iamTags []*iam.Tag, version string) (bool, error) {
if len(iamTags) == 0 {
return false, nil
}

wantedVersion, err := semver.NewVersion(version)
if err != nil {
return false, err
}

for _, tag := range iamTags {
if aws.StringValue(tag.Key) == OpenShiftVersion {
if version == aws.StringValue(tag.Value) {
return true, nil
}

currentVersion, err := semver.NewVersion(aws.StringValue(tag.Value))
if err != nil {
return false, err
}
return currentVersion.GreaterThanOrEqual(wantedVersion), nil
}
}
return false, nil
}

func IamResourceHasTag(iamTags []*iam.Tag, tagKey string, tagValue string) bool {
for _, tag := range iamTags {
if aws.StringValue(tag.Key) == tagKey && aws.StringValue(tag.Value) == tagValue {
Expand Down
50 changes: 0 additions & 50 deletions pkg/aws/validations/iam_helpers_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,56 +64,6 @@ var _ = Describe("AWS IAM Functions", func() {
})
})

var _ = Describe("HasCompatibleVersionTags", func() {
var iamTags []*iam.Tag

BeforeEach(func() {
iamTags = []*iam.Tag{
{Key: aws.String(OpenShiftVersion), Value: aws.String("1.2.3")},
{Key: aws.String("SomeOtherTag"), Value: aws.String("value")},
}
})

It("should return true if the version tag matches the provided version", func() {
version := "1.2.3"

result, err := HasCompatibleVersionTags(iamTags, version)

Expect(result).To(BeTrue())
Expect(err).To(BeNil())
})

It("should return false if the version tag does not match the provided version", func() {
version := "2.0.0"

result, err := HasCompatibleVersionTags(iamTags, version)

Expect(result).To(BeFalse())
Expect(err).To(BeNil())
})

It("should return false if the version tag is not present", func() {
version := "1.2.3"
iamTags = []*iam.Tag{
{Key: aws.String("SomeOtherTag"), Value: aws.String("value")},
}

result, err := HasCompatibleVersionTags(iamTags, version)

Expect(result).To(BeFalse())
Expect(err).To(BeNil())
})

It("should return an error if the provided version is not a valid semantic version", func() {
version := "invalid-version"

result, err := HasCompatibleVersionTags(iamTags, version)

Expect(result).To(BeFalse())
Expect(err).ToNot(BeNil())
})
})

var _ = Describe("IamResourceHasTag", func() {
It("should return true if the tag with the specified key and value exists", func() {
iamTags := []*iam.Tag{
Expand Down

0 comments on commit f330f50

Please sign in to comment.