Skip to content

Commit

Permalink
Merge pull request #690 from weherdh/updatelistaddon
Browse files Browse the repository at this point in the history
Update to use addon service API for addons function
  • Loading branch information
ciaranRoche authored Nov 1, 2024
2 parents c2a39c6 + 9fbb753 commit 66e2db1
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
1 change: 0 additions & 1 deletion cmd/ocm/list/addon/cmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import (
"github.com/openshift-online/ocm-cli/pkg/ocm"
"github.com/openshift-online/ocm-cli/pkg/output"
cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"

"github.com/spf13/cobra"
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ require (
github.com/nwidger/jsoncolor v0.3.2
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.8
github.com/openshift-online/ocm-sdk-go v0.1.445
github.com/openshift-online/ocm-sdk-go v0.1.447
github.com/openshift/rosa v1.2.24
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8
github.com/pkg/errors v0.9.1
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,8 @@ github.com/onsi/ginkgo/v2 v2.11.0 h1:WgqUCUt/lT6yXoQ8Wef0fsNn5cAuMK7+KT9UFRz2tcU
github.com/onsi/ginkgo/v2 v2.11.0/go.mod h1:ZhrRA5XmEE3x3rhlzamx/JJvujdZoJ2uvgI7kR0iZvM=
github.com/onsi/gomega v1.27.8 h1:gegWiwZjBsf2DgiSbf5hpokZ98JVDMcWkUiigk6/KXc=
github.com/onsi/gomega v1.27.8/go.mod h1:2J8vzI/s+2shY9XHRApDkdgPo1TKT7P2u6fXeJKFnNQ=
github.com/openshift-online/ocm-sdk-go v0.1.445 h1:NfaY+biXaREPnGYxa8G2zS2OZpN06yNnDR95sZoqKUQ=
github.com/openshift-online/ocm-sdk-go v0.1.445/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/openshift/rosa v1.2.24 h1:vv0yYnWHx6CCPEAau/0rS54P2ksaf+uWXb1TQPWxiYE=
github.com/openshift/rosa v1.2.24/go.mod h1:MVXB27O3PF8WoOic23I03mmq6/9kVxpFx6FKyLMCyrQ=
github.com/pkg/browser v0.0.0-20210911075715-681adbf594b8 h1:KoWmjvw+nsYOo29YJK9vDA65RGE3NrOnUtO7a+RF9HU=
Expand Down
11 changes: 6 additions & 5 deletions pkg/cluster/cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import (

sdk "github.com/openshift-online/ocm-sdk-go"
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"
)

Expand Down Expand Up @@ -755,7 +756,7 @@ func GetClusterAddOns(connection *sdk.Connection, clusterID string) ([]*AddOnIte
quotaCosts := quotaCostResponse.Items()

// Get complete list of enabled add-ons
addOnsResponse, err := connection.ClustersMgmt().V1().Addons().
addOnsResponse, err := connection.AddonsMgmt().V1().Addons().
List().
Search("enabled='t'").
Page(1).
Expand All @@ -767,7 +768,7 @@ func GetClusterAddOns(connection *sdk.Connection, clusterID string) ([]*AddOnIte
addOns := addOnsResponse.Items()

// Get add-ons already installed on cluster
addOnInstallationsResponse, err := connection.ClustersMgmt().V1().Clusters().
addOnInstallationsResponse, err := connection.AddonsMgmt().V1().Clusters().
Cluster(clusterID).
Addons().
List().
Expand All @@ -782,7 +783,7 @@ func GetClusterAddOns(connection *sdk.Connection, clusterID string) ([]*AddOnIte
var clusterAddOns []*AddOnItem

// Populate add-on installations with all add-on metadata
addOns.Each(func(addOn *cmv1.AddOn) bool {
addOns.Each(func(addOn *asv1.Addon) bool {
if addOn.ID() != "rhmi" {
clusterAddOn := AddOnItem{
ID: addOn.ID(),
Expand All @@ -805,11 +806,11 @@ func GetClusterAddOns(connection *sdk.Connection, clusterID string) ([]*AddOnIte
})

// Get the state of add-on installations on the cluster
addOnInstallations.Each(func(addOnInstallation *cmv1.AddOnInstallation) bool {
addOnInstallations.Each(func(addOnInstallation *asv1.AddonInstallation) bool {
if addOn.ID() == addOnInstallation.Addon().ID() {
clusterAddOn.State = string(addOnInstallation.State())
if clusterAddOn.State == "" {
clusterAddOn.State = string(cmv1.AddOnInstallationStateInstalling)
clusterAddOn.State = string(asv1.AddonInstallationStateInstalling)
}
}
return true
Expand Down
4 changes: 2 additions & 2 deletions pkg/urls/url_expander.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ var listResourceURLs = map[string]string{
"roles": "/api/accounts_mgmt/v1/roles",
"skus": "/api/accounts_mgmt/v1/skus",
"sku_rules": "/api/accounts_mgmt/v1/sku_rules",
"addons": "/api/clusters_mgmt/v1/addons",
"addons": "/api/addons_mgmt/v1/addons",
"clusters": "/api/clusters_mgmt/v1/clusters",
"versions": "/api/clusters_mgmt/v1/versions",
}
Expand All @@ -52,7 +52,7 @@ var individualResourceURLs = map[string]string{
"sku": "/api/accounts_mgmt/v1/skus/%s",
"sku_rule": "/api/accounts_mgmt/v1/sku_rules/%s",
"cluster": "/api/clusters_mgmt/v1/clusters/%s",
"addon": "/api/clusters_mgmt/v1/addons/%s",
"addon": "/api/addons_mgmt/v1/addons/%s",
"version": "/api/clusters_mgmt/v1/versions/%s",
"idp": "idp/%s",
"limitedsupportreasons": "/api/clusters_mgmt/v1/clusters/%s/limited_support_reasons",
Expand Down

0 comments on commit 66e2db1

Please sign in to comment.