11package support
22
33import (
4- "context"
5- "fmt"
6- "os"
7- "strings"
8-
94 "github.com/onsi/gomega"
5+
106 ocmsdk "github.com/openshift-online/ocm-sdk-go"
117 cmv1 "github.com/openshift-online/ocm-sdk-go/clustersmgmt/v1"
128)
139
14- var (
15- ClusterID string = os .Getenv ("CLUSTERID" )
16- TestName string = "test-instascale"
17- )
18-
1910func MachinePools (t Test , connection * ocmsdk.Connection ) func (g gomega.Gomega ) []* cmv1.MachinePool {
11+ osdClusterId , found := GetOsdClusterId ()
12+ t .Expect (found ).To (gomega .BeTrue (), "OSD cluster id not found, please configure environment properly" )
13+
2014 return func (g gomega.Gomega ) []* cmv1.MachinePool {
21- machinePoolsListResponse , err := connection .ClustersMgmt ().V1 ().Clusters ().Cluster (ClusterID ).MachinePools ().List ().Send ()
15+ machinePoolsListResponse , err := connection .ClustersMgmt ().V1 ().Clusters ().Cluster (osdClusterId ).MachinePools ().List ().Send ()
2216 g .Expect (err ).NotTo (gomega .HaveOccurred ())
2317 return machinePoolsListResponse .Items ().Slice ()
2418 }
@@ -32,21 +26,3 @@ func GetMachinePools(t Test, connection *ocmsdk.Connection) []*cmv1.MachinePool
3226func MachinePoolId (machinePool * cmv1.MachinePool ) string {
3327 return machinePool .ID ()
3428}
35-
36- func CheckNodePools (connection * ocmsdk.Connection , awName string ) (foundNodePool bool , err error ) {
37- nodePoolsConnection := connection .ClustersMgmt ().V1 ().Clusters ().Cluster (ClusterID ).NodePools ().List ()
38- nodePoolsListResponse , err := nodePoolsConnection .SendContext (context .Background ())
39- if err != nil {
40- return false , fmt .Errorf ("unable to send request, error: %v" , err )
41- }
42- nodePoolsList := nodePoolsListResponse .Items ()
43- nodePoolsList .Range (func (index int , item * cmv1.NodePool ) bool {
44- instanceName , _ := item .GetID ()
45- if strings .Contains (instanceName , awName ) {
46- foundNodePool = true
47- }
48- return true
49- })
50-
51- return foundNodePool , err
52- }
0 commit comments