@@ -10,8 +10,6 @@ import (
1010 cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
1111 mapiclientset "github.com/openshift/client-go/machine/clientset/versioned"
1212 "github.com/openshift/client-go/machine/listers/machine/v1beta1"
13- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14- "k8s.io/apimachinery/pkg/labels"
1513)
1614
1715var (
@@ -31,30 +29,20 @@ func CreateOCMConnection(secret string) (*ocmsdk.Connection, error) {
3129 Build ()
3230 if err != nil {
3331 fmt .Fprintf (os .Stderr , "Can't build logger: %v\n " , err )
34- os . Exit ( 1 )
32+ return nil , err
3533 }
3634 connection , err := ocmsdk .NewConnectionBuilder ().
3735 Logger (logger ).
3836 Tokens (string (secret )).
3937 Build ()
4038 if err != nil || connection == nil {
4139 fmt .Fprintf (os .Stderr , "Can't build connection: %v\n " , err )
42- os . Exit ( 1 )
40+ return nil , err
4341 }
4442
4543 return connection , nil
4644}
4745
48- func MachinePoolsExist (connection * ocmsdk.Connection ) (bool , error ) {
49- machinePools := connection .ClustersMgmt ().V1 ().Clusters ().Cluster (ClusterID ).MachinePools ()
50- return machinePools != nil , nil
51- }
52-
53- func NodePoolsExist (connection * ocmsdk.Connection ) (bool , error ) {
54- nodePools := connection .ClustersMgmt ().V1 ().Clusters ().Cluster (ClusterID ).NodePools ()
55- return nodePools != nil , nil
56- }
57-
5846func CheckMachinePools (connection * ocmsdk.Connection , awName string ) (foundMachinePool bool , err error ) {
5947 machinePoolsConnection := connection .ClustersMgmt ().V1 ().Clusters ().Cluster (ClusterID ).MachinePools ().List ()
6048 machinePoolsListResponse , err := machinePoolsConnection .Send ()
@@ -90,26 +78,3 @@ func CheckNodePools(connection *ocmsdk.Connection, awName string) (foundNodePool
9078
9179 return foundNodePool , err
9280}
93-
94- func MachineSetsCount () (numMachineSets int , err error ) {
95- machineSets , err := machineClient .MachineV1beta1 ().MachineSets (namespaceToList ).List (context .Background (), metav1.ListOptions {})
96- if err != nil {
97- return 0 , fmt .Errorf ("error while listing machine sets, error: %v" , err )
98- }
99- machineSetsSize := machineSets .ListMeta .Size ()
100-
101- return machineSetsSize , nil
102- }
103-
104- func CheckMachineSets (awName string ) (foundMachineSet bool , err error ) {
105- machineSets , err := msLister .MachineSets ("" ).List (labels .Everything ())
106- if err != nil {
107- return false , fmt .Errorf ("error listing machine sets, error: %v" , err )
108- }
109- for _ , machineSet := range machineSets {
110- if strings .Contains (machineSet .Name , awName ) {
111- foundMachineSet = true
112- }
113- }
114- return foundMachineSet , err
115- }
0 commit comments