forked from openshift/rosa
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
OCM-12362 | feat: Add HCP shared-vpc support to accountroles
- Loading branch information
1 parent
7c02b05
commit c4fad7a
Showing
18 changed files
with
372 additions
and
154 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
package accountroles | ||
|
||
import ( | ||
errors "github.com/zgalor/weberr" | ||
|
||
"github.com/openshift/rosa/pkg/arguments" | ||
) | ||
|
||
func validateSharedVpcInputs(hostedCp bool, vpcEndpointRoleArn string, | ||
route53RoleArn string) (bool, error) { | ||
if hostedCp { | ||
if vpcEndpointRoleArn != "" && route53RoleArn == "" { | ||
return false, errors.UserErrorf( | ||
arguments.MustUseBothFlagsErrorMessage, | ||
route53RoleArnFlag, | ||
vpcEndpointRoleArnFlag, | ||
) | ||
} | ||
|
||
if route53RoleArn != "" && vpcEndpointRoleArn == "" { | ||
return false, errors.UserErrorf( | ||
arguments.MustUseBothFlagsErrorMessage, | ||
vpcEndpointRoleArnFlag, | ||
route53RoleArnFlag, | ||
) | ||
} | ||
} | ||
|
||
return hostedCp && vpcEndpointRoleArn != "" && route53RoleArn != "", nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package accountroles | ||
|
||
import ( | ||
"go.uber.org/mock/gomock" | ||
|
||
. "github.com/onsi/ginkgo/v2" | ||
. "github.com/onsi/gomega" | ||
|
||
"github.com/openshift/rosa/pkg/arguments" | ||
) | ||
|
||
var _ = Describe("Validate Shared VPC Inputs", func() { | ||
var ctrl *gomock.Controller | ||
|
||
BeforeEach(func() { | ||
ctrl = gomock.NewController(GinkgoT()) | ||
}) | ||
AfterEach(func() { | ||
ctrl.Finish() | ||
}) | ||
|
||
Context("validateSharedVpcInputs", func() { | ||
When("Validate flags properly for shared VPC for HCP op roles", func() { | ||
It("OK: Should pass with no error, for classic (return false)", func() { | ||
usingSharedVpc, err := validateSharedVpcInputs(false, "", "") | ||
Expect(usingSharedVpc).To(BeFalse()) | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
It("OK: Should pass with no error, for HCP (return false)", func() { | ||
usingSharedVpc, err := validateSharedVpcInputs(true, "", "") | ||
Expect(usingSharedVpc).To(BeFalse()) | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
It("OK: Should pass with no error, for HCP (return true)", func() { | ||
usingSharedVpc, err := validateSharedVpcInputs(true, "123", "123") | ||
Expect(usingSharedVpc).To(BeTrue()) | ||
Expect(err).ToNot(HaveOccurred()) | ||
}) | ||
It("KO: Should error when using HCP and the first flag but not the second (return false)", func() { | ||
usingSharedVpc, err := validateSharedVpcInputs(true, "123", "") | ||
Expect(usingSharedVpc).To(BeFalse()) | ||
Expect(err).To(HaveOccurred()) | ||
Expect(err.Error()).To(ContainSubstring(arguments.MustUseBothFlagsErrorMessage, | ||
route53RoleArnFlag, | ||
vpcEndpointRoleArnFlag, | ||
)) | ||
}) | ||
It("KO: Should error when using HCP and the second flag but not the first (return false)", func() { | ||
usingSharedVpc, err := validateSharedVpcInputs(true, "", "123") | ||
Expect(usingSharedVpc).To(BeFalse()) | ||
Expect(err).To(HaveOccurred()) | ||
Expect(err.Error()).To(ContainSubstring(arguments.MustUseBothFlagsErrorMessage, | ||
vpcEndpointRoleArnFlag, | ||
route53RoleArnFlag, | ||
)) | ||
}) | ||
}) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.