Skip to content

Commit

Permalink
Merge pull request #665 from jbpratt/fix-cluster-create-json
Browse files Browse the repository at this point in the history
fix json output for cluster creation (sts+mode=auto)
  • Loading branch information
openshift-merge-robot authored Apr 4, 2022
2 parents 5a0eb08 + 014522f commit cc230ed
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 6 deletions.
8 changes: 6 additions & 2 deletions cmd/create/cluster/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -1787,9 +1787,13 @@ func run(cmd *cobra.Command, _ []string) {

if isSTS {
if mode != "" {
reporter.Infof("Preparing to create operator roles.")
if !output.HasFlag() || reporter.IsTerminal() {
reporter.Infof("Preparing to create operator roles.")
}
operatorroles.Cmd.Run(operatorroles.Cmd, []string{clusterName, mode, permissionsBoundary})
reporter.Infof("Preparing to create OIDC Provider.")
if !output.HasFlag() || reporter.IsTerminal() {
reporter.Infof("Preparing to create OIDC Provider.")
}
oidcprovider.Cmd.Run(oidcprovider.Cmd, []string{clusterName, mode})
} else {
rolesCMD := fmt.Sprintf("rosa create operator-roles --cluster %s", clusterName)
Expand Down
9 changes: 7 additions & 2 deletions cmd/create/oidcprovider/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"github.com/openshift/rosa/pkg/interactive/confirm"
"github.com/openshift/rosa/pkg/logging"
"github.com/openshift/rosa/pkg/ocm"
"github.com/openshift/rosa/pkg/output"
rprtr "github.com/openshift/rosa/pkg/reporter"
)

Expand Down Expand Up @@ -169,7 +170,9 @@ func run(cmd *cobra.Command, argv []string) {
"Verify that the cluster operator roles exist and are configured correctly.", clusterKey)
os.Exit(1)
}
reporter.Infof("Creating OIDC provider using '%s'", creator.ARN)
if !output.HasFlag() || reporter.IsTerminal() {
reporter.Infof("Creating OIDC provider using '%s'", creator.ARN)
}
if !confirm.Prompt(true, "Create the OIDC provider for cluster '%s'?", clusterKey) {
os.Exit(0)
}
Expand Down Expand Up @@ -223,7 +226,9 @@ func createProvider(reporter *rprtr.Object, awsClient aws.Client, cluster *cmv1.
if err != nil {
return err
}
reporter.Infof("Created OIDC provider with ARN '%s'", oidcProviderARN)
if !output.HasFlag() || reporter.IsTerminal() {
reporter.Infof("Created OIDC provider with ARN '%s'", oidcProviderARN)
}

return nil
}
Expand Down
9 changes: 7 additions & 2 deletions cmd/create/operatorroles/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import (
"github.com/openshift/rosa/pkg/interactive/confirm"
"github.com/openshift/rosa/pkg/logging"
"github.com/openshift/rosa/pkg/ocm"
"github.com/openshift/rosa/pkg/output"
rprtr "github.com/openshift/rosa/pkg/reporter"
)

Expand Down Expand Up @@ -227,7 +228,9 @@ func run(cmd *cobra.Command, argv []string) {
}
switch mode {
case aws.ModeAuto:
reporter.Infof("Creating roles using '%s'", creator.ARN)
if !output.HasFlag() || reporter.IsTerminal() {
reporter.Infof("Creating roles using '%s'", creator.ARN)
}
err = createRoles(reporter, awsClient, prefix, permissionsBoundary, cluster, creator.AccountID,
accountRoleVersion)
if err != nil {
Expand Down Expand Up @@ -325,7 +328,9 @@ func createRoles(reporter *rprtr.Object, awsClient aws.Client,
if err != nil {
return err
}
reporter.Infof("Created role '%s' with ARN '%s'", roleName, roleARN)
if !output.HasFlag() || reporter.IsTerminal() {
reporter.Infof("Created role '%s' with ARN '%s'", roleName, roleARN)
}

reporter.Debugf("Attaching permission policy '%s' to role '%s'", policyARN, roleName)
err = awsClient.AttachRolePolicy(roleName, policyARN)
Expand Down

0 comments on commit cc230ed

Please sign in to comment.