Skip to content

Commit

Permalink
Update to use addon service API for addons function
Browse files Browse the repository at this point in the history
  • Loading branch information
weherdh committed Oct 28, 2024
1 parent c2a39c6 commit b49b555
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 8 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: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,5 @@ require (
google.golang.org/protobuf v1.34.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect
)

replace github.com/openshift-online/ocm-sdk-go => github.com/venkateshsredhat/ocm-sdk-go v0.1.445-newtest
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -361,8 +361,6 @@ 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/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 Expand Up @@ -438,6 +436,8 @@ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO
github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4=
github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg=
github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
github.com/venkateshsredhat/ocm-sdk-go v0.1.445-newtest h1:nrbq5o2IFkMtUVgxbE+GC6ZgKxXDEfVubja/eXnR+OQ=
github.com/venkateshsredhat/ocm-sdk-go v0.1.445-newtest/go.mod h1:CiAu2jwl3ITKOxkeV0Qnhzv4gs35AmpIzVABQLtcI2Y=
github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
Expand Down
24 changes: 19 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,13 @@ 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.ClustersMgmt().V1().Addons().
// List().
// Search("enabled='t'").
// Page(1).
// Size(-1).
// Send()
addOnsResponse, err := connection.AddonsMgmt().V1().Addons().
List().
Search("enabled='t'").
Page(1).
Expand All @@ -767,7 +774,14 @@ 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.ClustersMgmt().V1().Clusters().
// Cluster(clusterID).
// Addons().
// List().
// Page(1).
// Size(-1).
// Send()
addOnInstallationsResponse, err := connection.AddonsMgmt().V1().Clusters().
Cluster(clusterID).
Addons().
List().
Expand All @@ -782,7 +796,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 +819,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

0 comments on commit b49b555

Please sign in to comment.