Skip to content

Commit

Permalink
OCM-12694 | fix: Pre-command validation for shared vpc flags
Browse files Browse the repository at this point in the history
  • Loading branch information
hunterkepley committed Nov 20, 2024
1 parent e3ae664 commit acbde75
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
15 changes: 15 additions & 0 deletions cmd/create/accountroles/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,21 @@ func run(cmd *cobra.Command, argv []string) {
os.Exit(1)
}

if args.vpcEndpointRoleArn != "" {
err = aws.ARNValidator(args.vpcEndpointRoleArn)
if err != nil {
r.Reporter.Errorf("Expected a valid policy ARN for %s: %s", vpcEndpointRoleArnFlag, err)
os.Exit(1)
}
}
if args.route53RoleArn != "" {
err = aws.ARNValidator(args.route53RoleArn)
if err != nil {
r.Reporter.Errorf("Expected a valid policy ARN for %s: %s", route53RoleArnFlag, err)
os.Exit(1)
}
}

// If necessary, call `login` as part of `init`. We do this before
// other validations to get the prompt out of the way before performing
// longer checks.
Expand Down
15 changes: 15 additions & 0 deletions cmd/create/operatorroles/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,21 @@ func run(cmd *cobra.Command, argv []string) {
os.Exit(1)
}

if args.vpcEndpointRoleArn != "" {
err = aws.ARNValidator(args.vpcEndpointRoleArn)
if err != nil {
r.Reporter.Errorf("Expected a valid policy ARN for %s: %s", vpcEndpointRoleArnFlag, err)
os.Exit(1)
}
}
if args.sharedVpcRoleArn != "" {
err = aws.ARNValidator(args.sharedVpcRoleArn)
if err != nil {
r.Reporter.Errorf("Expected a valid policy ARN for %s: %s", hostedZoneRoleArnFlag, err)
os.Exit(1)
}
}

env, err := ocm.GetEnv()
if err != nil {
r.Reporter.Errorf("Failed to determine OCM environment: %v", err)
Expand Down

0 comments on commit acbde75

Please sign in to comment.