@@ -40,13 +40,16 @@ const (
40
40
OsdClusterID = "CLUSTERID"
41
41
42
42
// Type of cluster test is run on
43
- ClusterType = "CLUSTER_TYPE"
44
- // OpenShift Dedicated Cluster
45
- OsdCluster = "OSD"
46
- // OpenShift Container Platform Cluster
47
- OcpCluster = "OCP"
48
- // ROSA Hosted Hypershift Cluster
49
- HypershiftCluster = "HYPERSHIFT"
43
+ ClusterTypeEnvVar = "CLUSTER_TYPE"
44
+ )
45
+
46
+ type ClusterType string
47
+
48
+ const (
49
+ OsdCluster ClusterType = "OSD"
50
+ OcpCluster ClusterType = "OCP"
51
+ HypershiftCluster ClusterType = "HYPERSHIFT"
52
+ UndefinedCluster ClusterType = "UNDEFINED"
50
53
)
51
54
52
55
func GetCodeFlareSDKVersion () string {
@@ -74,8 +77,23 @@ func GetOsdClusterId() (string, bool) {
74
77
return os .LookupEnv (OsdClusterID )
75
78
}
76
79
77
- func GetClusterType () (string , bool ) {
78
- return os .LookupEnv (ClusterType )
80
+ func GetClusterType (t Test ) ClusterType {
81
+ clusterType , ok := os .LookupEnv (ClusterTypeEnvVar )
82
+ if ! ok {
83
+ t .T ().Logf ("Expected environment variable %s not found, cluster type is not defined." , ClusterTypeEnvVar )
84
+ return UndefinedCluster
85
+ }
86
+ switch clusterType {
87
+ case "OSD" :
88
+ return OsdCluster
89
+ case "OCP" :
90
+ return OcpCluster
91
+ case "HYPERSHIFT" :
92
+ return HypershiftCluster
93
+ default :
94
+ t .T ().Logf ("Expected environment variable %s contains unexpected value: '%s'" , ClusterTypeEnvVar , clusterType )
95
+ return UndefinedCluster
96
+ }
79
97
}
80
98
81
99
func IsOsd () bool {
@@ -92,20 +110,3 @@ func lookupEnvOrDefault(key, value string) string {
92
110
}
93
111
return value
94
112
}
95
-
96
- func DetermineClusterType () string {
97
- clusterType , ok := GetClusterType ()
98
- if ! ok {
99
- return ""
100
- }
101
- switch clusterType {
102
- case "OSD" :
103
- return OsdCluster
104
- case "OCP" :
105
- return OcpCluster
106
- case "HYPERSHIFT" :
107
- return HypershiftCluster
108
- default :
109
- return ""
110
- }
111
- }
0 commit comments