Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OCM-0000| feat: removing unecessary function #17

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading