Skip to content

Commit

Permalink
Merge pull request #1944 from openshift/OCM-6595-RC2
Browse files Browse the repository at this point in the history
OCM-6595| chore: 1.2.38-RC2 cut with cherrypicked release blockers
  • Loading branch information
davidleerh committed Apr 18, 2024
2 parents 9b8c138 + 7c8f7eb commit 5371d6b
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 10 deletions.
2 changes: 1 addition & 1 deletion cmd/describe/cluster/cmd.go
Expand Up @@ -330,7 +330,7 @@ func run(cmd *cobra.Command, argv []string) {
}

deleteProtection := DisabledOutput
if !cluster.DeleteProtection().Enabled() {
if cluster.DeleteProtection().Enabled() {
deleteProtection = EnabledOutput
}

Expand Down
63 changes: 60 additions & 3 deletions cmd/list/instancetypes/cmd.go
Expand Up @@ -26,6 +26,9 @@ import (

"github.com/openshift/rosa/pkg/arguments"
"github.com/openshift/rosa/pkg/helper"
"github.com/openshift/rosa/pkg/interactive"
"github.com/openshift/rosa/pkg/interactive/confirm"
interactiveRoles "github.com/openshift/rosa/pkg/interactive/roles"
"github.com/openshift/rosa/pkg/ocm"
"github.com/openshift/rosa/pkg/output"
"github.com/openshift/rosa/pkg/rosa"
Expand All @@ -52,10 +55,46 @@ func init() {
initFlags(Cmd)
}

var args struct {
region string
installerRoleArn string
externalId string
hostedClusterEnabled bool
}

const (
InstallerRoleArnFlag = "role-arn"
)

func initFlags(cmd *cobra.Command) {
flags := cmd.Flags()

flags.BoolVar(
&args.hostedClusterEnabled,
"hosted-cp",
false,
"Enable the use of Hosted Control Planes",
)

flags.StringVar(
&args.externalId,
"external-id",
"",
"An optional unique identifier that might be required when you assume a role in another account.",
)

// normalizing installer role argument to support deprecated flag
flags.SetNormalizeFunc(arguments.NormalizeFlags)
flags.StringVar(
&args.installerRoleArn,
InstallerRoleArnFlag,
"",
"STS Role ARN with get secrets permission.",
)

arguments.AddRegionFlag(flags)
output.AddFlag(cmd)
confirm.AddFlag(flags)
}

func run(cmd *cobra.Command, _ []string) {
Expand All @@ -68,15 +107,33 @@ func run(cmd *cobra.Command, _ []string) {
}
}

func checkInteractiveModeNeeded(cmd *cobra.Command) {
installerRoleArnNotSet := (!cmd.Flags().Changed(InstallerRoleArnFlag) || args.installerRoleArn == "") &&
!confirm.Yes()
if installerRoleArnNotSet {
interactive.Enable()
}
}

func runWithRuntime(r *rosa.Runtime, cmd *cobra.Command) error {
checkInteractiveModeNeeded(cmd)
r.Reporter.Debugf("Fetching instance types")

var machineTypes ocm.MachineTypeList
if cmd.Flags().Changed("region") {
if interactive.Enabled() || (confirm.Yes() && args.installerRoleArn == "") {
args.installerRoleArn = interactiveRoles.
GetInstallerRoleArn(
r,
cmd,
args.installerRoleArn,
"",
r.AWSClient.FindRoleARNs,
)
}
var availabilityZones []string
roleArn := ""
regionList, _, err := r.OCMClient.GetRegionList(false, "", "", "",
r.AWSClient, false, false)
regionList, _, err := r.OCMClient.GetRegionList(false, args.installerRoleArn, args.externalId, "",
r.AWSClient, args.hostedClusterEnabled, false)
if err != nil {
return err
}
Expand Down
16 changes: 11 additions & 5 deletions cmd/list/instancetypes/cmd_test.go
Expand Up @@ -179,9 +179,11 @@ var _ = Describe("list instance-types", func() {
]
}
`
regionSuccessOutput = `ID CATEGORY CPU_CORES MEMORY
regionSuccessOutput = `INFO: Using fake_installer_arn for the Installer role
ID CATEGORY CPU_CORES MEMORY
g4dn.12xlarge accelerated_computing 48 192.0 GiB
`
mockAwsClient *aws.MockClient
)

BeforeEach(func() {
Expand Down Expand Up @@ -226,9 +228,9 @@ g4dn.12xlarge accelerated_computing 48 192.0 GiB
}

ctrl := gomock.NewController(GinkgoT())
awsClient := aws.NewMockClient(ctrl)
r.AWSClient = awsClient
awsClient.EXPECT().GetAWSAccessKeys().Return(&aws.AccessKey{
mockAwsClient = aws.NewMockClient(ctrl)
r.AWSClient = mockAwsClient
mockAwsClient.EXPECT().GetAWSAccessKeys().Return(&aws.AccessKey{
AccessKeyID: "abc123",
SecretAccessKey: "abc123",
}, nil).AnyTimes()
Expand All @@ -245,6 +247,8 @@ g4dn.12xlarge accelerated_computing 48 192.0 GiB

cmd.Flags().Set("region", "us-east-1")

mockAwsClient.EXPECT().FindRoleARNs(aws.InstallerAccountRole, "").Return([]string{"fake_installer_arn"}, nil)

// POST /api/clusters_mgmt/v1/aws_inquiries/machine_types
apiServer.AppendHandlers(
RespondWithJSON(
Expand Down Expand Up @@ -287,6 +291,8 @@ g4dn.12xlarge accelerated_computing 48 192.0 GiB

cmd.Flags().Set("region", "us-east-xyz")

mockAwsClient.EXPECT().FindRoleARNs(aws.InstallerAccountRole, "").Return([]string{"fake_installer_arn"}, nil)

// POST /api/clusters_mgmt/v1/aws_inquiries/machine_types
apiServer.AppendHandlers(
RespondWithJSON(
Expand All @@ -300,7 +306,7 @@ g4dn.12xlarge accelerated_computing 48 192.0 GiB
Expect(err.Error()).To(
ContainSubstring("Region 'us-east-xyz' not found."))
Expect(stderr).To(Equal(""))
Expect(stdout).To(Equal(""))
Expect(stdout).To(Equal("INFO: Using fake_installer_arn for the Installer role\n"))
})

It("Succeeds", func() {
Expand Down
2 changes: 1 addition & 1 deletion pkg/info/info.go
Expand Up @@ -18,7 +18,7 @@ limitations under the License.

package info

const Version = "1.2.38-RC1"
const Version = "1.2.38-RC2"

// Build contains the short Git SHA of the CLI at the point it was build. Set via `-ldflags` at build time
var Build = "local"
Expand Down

0 comments on commit 5371d6b

Please sign in to comment.