Skip to content

Commit

Permalink
OCM-1988 | chore: update ROSA CLI with the latest ocm sdk to use addo…
Browse files Browse the repository at this point in the history
…ns_mgmt
  • Loading branch information
venkateshsredhat committed Oct 28, 2024
1 parent bcd361b commit 4a72043
Show file tree
Hide file tree
Showing 79 changed files with 16,267 additions and 11,584 deletions.
4 changes: 2 additions & 2 deletions cmd/create/service/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import (

awssdk "github.com/aws/aws-sdk-go-v2/aws"
ocmConsts "github.com/openshift-online/ocm-common/pkg/ocm/consts"
cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
asv1 "github.com/openshift-online/ocm-sdk-go/addonsmgmt/v1"
"github.com/spf13/cobra"
"github.com/spf13/pflag"

Expand Down Expand Up @@ -200,7 +200,7 @@ func run(cmd *cobra.Command, argv []string) {
if parameters.Len() > 0 {
args.Parameters = map[string]string{}
// Determine if all required parameters have already been set as flags.
parameters.Each(func(param *cmv1.AddOnParameter) bool {
parameters.Each(func(param *asv1.AddonParameter) bool {
flag := cmd.Flags().Lookup(param.ID())
if param.Required() && (flag == nil || flag.Value.String() == "") {
r.Reporter.Errorf("Required parameter --%s missing", param.ID())
Expand Down
10 changes: 5 additions & 5 deletions cmd/describe/addon/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
"regexp"
"strings"

cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
asv1 "github.com/openshift-online/ocm-sdk-go/addonsmgmt/v1"
"github.com/spf13/cobra"

"github.com/openshift/rosa/pkg/rosa"
Expand Down Expand Up @@ -65,7 +65,7 @@ func run(_ *cobra.Command, argv []string) {
printParameters(addOn.Parameters())
}

func printDescription(addOn *cmv1.AddOn) {
func printDescription(addOn *asv1.Addon) {
fmt.Printf("ADD-ON\n"+
"ID: %s\n"+
"Name: %s\n"+
Expand All @@ -85,7 +85,7 @@ func printDescription(addOn *cmv1.AddOn) {
fmt.Println()
}

func printCredentialRequests(requests []*cmv1.CredentialRequest) {
func printCredentialRequests(requests []*asv1.CredentialRequest) {
if len(requests) > 0 {
fmt.Printf("CREDENTIALS REQUESTS\n")
for _, cr := range requests {
Expand All @@ -108,10 +108,10 @@ func printCredentialRequests(requests []*cmv1.CredentialRequest) {
fmt.Println()
}

func printParameters(params *cmv1.AddOnParameterList) {
func printParameters(params *asv1.AddonParameterList) {
if params.Len() > 0 {
fmt.Printf("ADD-ON PARAMETERS\n")
params.Each(func(param *cmv1.AddOnParameter) bool {
params.Each(func(param *asv1.AddonParameter) bool {
if !param.Enabled() {
return true
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/describe/installation/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import (
"fmt"
"os"

cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
asv1 "github.com/openshift-online/ocm-sdk-go/addonsmgmt/v1"
"github.com/spf13/cobra"

"github.com/openshift/rosa/pkg/ocm"
Expand Down Expand Up @@ -106,8 +106,8 @@ func describeAddonInstallation(r *rosa.Runtime, installationKey string) error {
if parameters.Len() > 0 {
fmt.Println("Parameters:")
}
parameters.Each(func(parameter *cmv1.AddOnInstallationParameter) bool {
fmt.Printf("\t%-28q: %q\n", parameter.ID(), parameter.Value())
parameters.Each(func(parameter *asv1.AddonInstallationParameter) bool {
fmt.Printf("\t%-28q: %q\n", parameter.Id(), parameter.Value())
return true
})

Expand Down
11 changes: 6 additions & 5 deletions cmd/edit/addon/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"regexp"
"strings"

asv1 "github.com/openshift-online/ocm-sdk-go/addonsmgmt/v1"
cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
"github.com/spf13/cobra"

Expand Down Expand Up @@ -101,7 +102,7 @@ func run(cmd *cobra.Command, argv []string) {
// set as flags, then we also ensure that interactive mode is enabled so that the
// user gets prompted.
if arguments.HasUnknownFlags() {
addonParameters.Each(func(param *cmv1.AddOnParameter) bool {
addonParameters.Each(func(param *asv1.AddonParameter) bool {
flag := cmd.Flags().Lookup(param.ID())
if flag != nil && !param.Editable() {
r.Reporter.Errorf("Parameter '%s' on addon '%s' cannot be modified", param.ID(), addOnID)
Expand All @@ -114,11 +115,11 @@ func run(cmd *cobra.Command, argv []string) {
}

var addonArguments []ocm.AddOnParam
addonParameters.Each(func(param *cmv1.AddOnParameter) bool {
addonParameters.Each(func(param *asv1.AddonParameter) bool {
// Find the installation parameter corresponding to the addon parameter
var addOnInstallationParam *cmv1.AddOnInstallationParameter
addOnInstallation.Parameters().Each(func(p *cmv1.AddOnInstallationParameter) bool {
if p.ID() == param.ID() {
var addOnInstallationParam *asv1.AddonInstallationParameter
addOnInstallation.Parameters().Each(func(p *asv1.AddonInstallationParameter) bool {
if p.Id() == param.ID() {
addOnInstallationParam = p
return false
}
Expand Down
6 changes: 3 additions & 3 deletions cmd/edit/service/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package service
import (
"os"

cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
asv1 "github.com/openshift-online/ocm-sdk-go/addonsmgmt/v1"
"github.com/spf13/cobra"

"github.com/openshift/rosa/pkg/arguments"
Expand Down Expand Up @@ -84,7 +84,7 @@ func run(cmd *cobra.Command, argv []string) {
}

addonParameters := addOn.Parameters()
addonParameters.Each(func(param *cmv1.AddOnParameter) bool {
addonParameters.Each(func(param *asv1.AddonParameter) bool {
arguments.AddStringFlag(cmd, param.ID())
return true
})
Expand All @@ -96,7 +96,7 @@ func run(cmd *cobra.Command, argv []string) {
}

args.Parameters = map[string]string{}
addonParameters.Each(func(param *cmv1.AddOnParameter) bool {
addonParameters.Each(func(param *asv1.AddonParameter) bool {
flag := cmd.Flags().Lookup(param.ID())
// Checking if the flag changed to ensure that the user set the value.
if flag != nil && flag.Changed {
Expand Down
9 changes: 5 additions & 4 deletions cmd/install/addon/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import (
awserr "github.com/openshift-online/ocm-common/pkg/aws/errors"
awsCommonUtils "github.com/openshift-online/ocm-common/pkg/aws/utils"
amv1 "github.com/openshift-online/ocm-sdk-go/accountsmgmt/v1"
asv1 "github.com/openshift-online/ocm-sdk-go/addonsmgmt/v1"
cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
"github.com/spf13/cobra"
errors "github.com/zgalor/weberr"
Expand Down Expand Up @@ -180,7 +181,7 @@ func run(cmd *cobra.Command, argv []string) {
// set as flags, then we also ensure that interactive mode is enabled so that the
// user gets prompted.
if arguments.HasUnknownFlags() {
addonParameters.Each(func(param *cmv1.AddOnParameter) bool {
addonParameters.Each(func(param *asv1.AddonParameter) bool {
flag := cmd.Flags().Lookup(param.ID())
if param.Required() && (flag == nil || flag.Value.String() == "") {
interactive.Enable()
Expand All @@ -192,7 +193,7 @@ func run(cmd *cobra.Command, argv []string) {
interactive.Enable()
}

addonParameters.Each(func(param *cmv1.AddOnParameter) bool {
addonParameters.Each(func(param *asv1.AddonParameter) bool {
var val string
var options []string
var values []string
Expand Down Expand Up @@ -297,7 +298,7 @@ func ensureAddonNotInstalled(r *rosa.Runtime, clusterID, addOnID string) {
}
}

func createAddonRole(r *rosa.Runtime, roleName string, cr *cmv1.CredentialRequest, cmd *cobra.Command,
func createAddonRole(r *rosa.Runtime, roleName string, cr *asv1.CredentialRequest, cmd *cobra.Command,
cluster *cmv1.Cluster) error {
policy := aws.NewPolicyDocument()
policy.AllowActions(cr.PolicyPermissions()...)
Expand Down Expand Up @@ -354,7 +355,7 @@ func buildCommand(
return command
}

func generateRoleName(cr *cmv1.CredentialRequest, prefix string) string {
func generateRoleName(cr *asv1.CredentialRequest, prefix string) string {
roleName := fmt.Sprintf("%s-%s-%s", prefix, cr.Namespace(), cr.Name())
return awsCommonUtils.TruncateRoleName(roleName)
}
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ require (
github.com/onsi/ginkgo/v2 v2.17.1
github.com/onsi/gomega v1.30.0
github.com/openshift-online/ocm-common v0.0.12
github.com/openshift-online/ocm-sdk-go v0.1.440
github.com/openshift-online/ocm-sdk-go v0.1.447
github.com/pkg/errors v0.9.1
github.com/robfig/cron/v3 v3.0.1
github.com/sirupsen/logrus v1.9.3
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -275,8 +275,8 @@ github.com/onsi/gomega v1.30.0 h1:hvMK7xYz4D3HapigLTeGdId/NcfQx1VHMJc60ew99+8=
github.com/onsi/gomega v1.30.0/go.mod h1:9sxs+SwGrKI0+PWe4Fxa9tFQQBG5xSsSbMXOI8PPpoQ=
github.com/openshift-online/ocm-common v0.0.12 h1:2oGZCXd8O/nZVlM0pvTtm3hDGbW/ncTtvSLLB+nuQf0=
github.com/openshift-online/ocm-common v0.0.12/go.mod h1:6MWje2NFNJ3IWpGs7BYj6DWagWXHyp8EnmYY7XFTtI4=
github.com/openshift-online/ocm-sdk-go v0.1.440 h1:qHVF8iZ0V3DPPuZq2LF7pwQKVsm0W0QxVDoXxDS7oyw=
github.com/openshift-online/ocm-sdk-go v0.1.440/go.mod h1:CiAu2jwl3ITKOxkeV0Qnhzv4gs35AmpIzVABQLtcI2Y=
github.com/openshift-online/ocm-sdk-go v0.1.447 h1:PLau6NVgTpwL+L5OcKrBZm+HbET34tjHbENd2GsFhRw=
github.com/openshift-online/ocm-sdk-go v0.1.447/go.mod h1:CiAu2jwl3ITKOxkeV0Qnhzv4gs35AmpIzVABQLtcI2Y=
github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=
Expand Down
3 changes: 2 additions & 1 deletion pkg/aws/policy_document.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/service/iam"
iamtypes "github.com/aws/aws-sdk-go-v2/service/iam/types"
asv1 "github.com/openshift-online/ocm-sdk-go/addonsmgmt/v1"
cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
)

Expand Down Expand Up @@ -314,7 +315,7 @@ func GenerateOperatorRolePolicyDoc(partition string, cluster *cmv1.Cluster,
accountID, operator, policyDetails)
}

func GenerateAddonPolicyDoc(partition string, cluster *cmv1.Cluster, accountID string, cr *cmv1.CredentialRequest,
func GenerateAddonPolicyDoc(partition string, cluster *cmv1.Cluster, accountID string, cr *asv1.CredentialRequest,
policyDetails string) (string, error) {
service_accounts := fmt.Sprintf("system:serviceaccount:%s:%s", cr.Namespace(), cr.ServiceAccount())
return GenerateRolePolicyDoc(partition, cluster.AWS().STS().OIDCEndpointURL(),
Expand Down
6 changes: 3 additions & 3 deletions pkg/interactive/addon.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ import (
"strconv"
"strings"

cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
asv1 "github.com/openshift-online/ocm-sdk-go/addonsmgmt/v1"
)

func GetAddonArgument(param cmv1.AddOnParameter, dflt string) (string, error) {
func GetAddonArgument(param asv1.AddonParameter, dflt string) (string, error) {
var input = Input{
Question: param.Name(),
Help: fmt.Sprintf("%s: %s", param.ID(), param.Description()),
Expand Down Expand Up @@ -109,7 +109,7 @@ func GetAddonArgument(param cmv1.AddOnParameter, dflt string) (string, error) {
return "", fmt.Errorf("The parameter '%s' does not support interactive mode", param.ID())
}

func getOptionNames(param cmv1.AddOnParameter) []string {
func getOptionNames(param asv1.AddonParameter) []string {
var optionNames []string
options, _ := param.GetOptions()
for _, option := range options {
Expand Down
Loading

0 comments on commit 4a72043

Please sign in to comment.