Skip to content

Commit

Permalink
Merge pull request openshift#541 from pvasant/sda5074-fixorgadminvali…
Browse files Browse the repository at this point in the history
…dation

fix org admin validation
  • Loading branch information
openshift-merge-robot authored Nov 30, 2021
2 parents 7539a7b + abfe1c5 commit defeb65
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
3 changes: 2 additions & 1 deletion cmd/link/ocmrole/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ package ocmrole

import (
"os"
"strings"

"github.com/aws/aws-sdk-go/aws/arn"
"github.com/spf13/cobra"
Expand Down Expand Up @@ -135,7 +136,7 @@ func run(cmd *cobra.Command, argv []string) (err error) {

err = ocmClient.LinkOrgToRole(orgAccount, roleArn)
if err != nil {
if errors.GetType(err) == errors.Forbidden {
if errors.GetType(err) == errors.Forbidden || strings.Contains(err.Error(), "ACCT-MGMT-11") {
reporter.Errorf("Only organization admin can run this command. "+
"Please ask someone with the organization admin role to run the following command \n\n"+
"\t rosa link ocm-role --role-arn %s --organization-id %s", roleArn, orgAccount)
Expand Down
12 changes: 11 additions & 1 deletion cmd/link/userrole/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,19 @@ package userrole

import (
"os"
"strings"

"github.com/aws/aws-sdk-go/aws/arn"
"github.com/spf13/cobra"
errors "github.com/zgalor/weberr"

"github.com/openshift/rosa/pkg/aws"
"github.com/openshift/rosa/pkg/interactive"
"github.com/openshift/rosa/pkg/interactive/confirm"
"github.com/openshift/rosa/pkg/logging"
"github.com/openshift/rosa/pkg/ocm"

rprtr "github.com/openshift/rosa/pkg/reporter"
"github.com/spf13/cobra"
)

var args struct {
Expand Down Expand Up @@ -135,6 +139,12 @@ func run(cmd *cobra.Command, argv []string) (err error) {

err = ocmClient.LinkAccountRole(accountID, roleArn)
if err != nil {
if errors.GetType(err) == errors.Forbidden || strings.Contains(err.Error(), "ACCT-MGMT-11") {
reporter.Errorf("Only organization admin can run this command. "+
"Please ask someone with the organization admin role to run the following command \n\n"+
"\t rosa link user-role --role-arn %s --account-id %s", roleArn, accountID)
return err
}
reporter.Errorf("Unable to link role arn '%s' with the account id : '%s' : %v",
args.roleArn, accountID, err)
return err
Expand Down

0 comments on commit defeb65

Please sign in to comment.