Skip to content

Commit ced9b72

Browse files
sutaakarFiona-Waters
authored andcommitted
Move OSD cluster ID into codeflare.go
1 parent e7a93b6 commit ced9b72

File tree

4 files changed

+15
-30
lines changed

4 files changed

+15
-30
lines changed

test/support/clusterpools.go

Lines changed: 5 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
11
package support
22

33
import (
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-
1910
func 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
3226
func 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-
}

test/support/codeflare.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ const (
3636
InstaScaleOcmSecretName = "INSTASCALE_OCM_SECRET_NAME"
3737
// The namespace where a secret containing InstaScale OCM token is stored.
3838
InstaScaleOcmSecretNamespace = "INSTASCALE_OCM_SECRET_NAMESPACE"
39+
// Cluster ID for OSD cluster used in tests, used for testing InstaScale
40+
OsdClusterID = "CLUSTERID"
3941
)
4042

4143
func GetCodeFlareSDKVersion() string {
@@ -62,6 +64,10 @@ func GetInstaScaleOcmSecretNamespace() string {
6264
return lookupEnvOrDefault(InstaScaleOcmSecretNamespace, "default")
6365
}
6466

67+
func GetOsdClusterId() (string, bool) {
68+
return os.LookupEnv(OsdClusterID)
69+
}
70+
6571
func lookupEnvOrDefault(key, value string) string {
6672
if v, ok := os.LookupEnv(key); ok {
6773
return v

test/support/config_map.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package support
1818

1919
import (
2020
"github.com/onsi/gomega"
21+
2122
corev1 "k8s.io/api/core/v1"
2223
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2324
)

test/support/ocm.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,10 @@ import (
2121
"os"
2222

2323
"github.com/onsi/gomega"
24-
ocmsdk "github.com/openshift-online/ocm-sdk-go"
24+
2525
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
26+
27+
ocmsdk "github.com/openshift-online/ocm-sdk-go"
2628
)
2729

2830
func CreateOCMConnection(test Test) *ocmsdk.Connection {

0 commit comments

Comments
 (0)