@@ -10,8 +10,6 @@ import (
10
10
cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
11
11
mapiclientset "github.com/openshift/client-go/machine/clientset/versioned"
12
12
"github.com/openshift/client-go/machine/listers/machine/v1beta1"
13
- metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
14
- "k8s.io/apimachinery/pkg/labels"
15
13
)
16
14
17
15
var (
@@ -31,30 +29,20 @@ func CreateOCMConnection(secret string) (*ocmsdk.Connection, error) {
31
29
Build ()
32
30
if err != nil {
33
31
fmt .Fprintf (os .Stderr , "Can't build logger: %v\n " , err )
34
- os . Exit ( 1 )
32
+ return nil , err
35
33
}
36
34
connection , err := ocmsdk .NewConnectionBuilder ().
37
35
Logger (logger ).
38
36
Tokens (string (secret )).
39
37
Build ()
40
38
if err != nil || connection == nil {
41
39
fmt .Fprintf (os .Stderr , "Can't build connection: %v\n " , err )
42
- os . Exit ( 1 )
40
+ return nil , err
43
41
}
44
42
45
43
return connection , nil
46
44
}
47
45
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
-
58
46
func CheckMachinePools (connection * ocmsdk.Connection , awName string ) (foundMachinePool bool , err error ) {
59
47
machinePoolsConnection := connection .ClustersMgmt ().V1 ().Clusters ().Cluster (ClusterID ).MachinePools ().List ()
60
48
machinePoolsListResponse , err := machinePoolsConnection .Send ()
@@ -90,26 +78,3 @@ func CheckNodePools(connection *ocmsdk.Connection, awName string) (foundNodePool
90
78
91
79
return foundNodePool , err
92
80
}
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