@@ -19,16 +19,6 @@ import (
19
19
"github.com/samba-in-kubernetes/samba-operator/internal/conf"
20
20
)
21
21
22
- // ClusterType reperesnts the sub-kind of k8s cluster type.
23
- type ClusterType string
24
-
25
- const (
26
- // ClusterTypeDefault defines the default value for cluster type
27
- ClusterTypeDefault = "default"
28
- // ClusterTypeOpenshift defines the type-name for OpenShift clusters
29
- ClusterTypeOpenshift = "openshift"
30
- )
31
-
32
22
const (
33
23
openshiftFinalizer = "samba-operator.samba.org/openshiftFinalizer"
34
24
serviceAccountName = "samba"
@@ -46,7 +36,7 @@ type OpenShiftManager struct {
46
36
client rtclient.Client
47
37
logger logr.Logger
48
38
cfg * conf.OperatorConfig
49
- ClusterType ClusterType
39
+ ClusterType string
50
40
}
51
41
52
42
// NewOpenShiftManager creates a ServiceAccountManager instance
@@ -68,7 +58,7 @@ func (m *OpenShiftManager) Process(
68
58
nsname types.NamespacedName ) Result {
69
59
// Do-nothing if not on OpenShift
70
60
m .resolveClusterType (ctx )
71
- if m .ClusterType != ClusterTypeOpenshift {
61
+ if m .ClusterType != conf . ClusterTypeOpenShift {
72
62
return Done
73
63
}
74
64
@@ -103,9 +93,9 @@ func (m *OpenShiftManager) Process(
103
93
// Cache cluster type
104
94
func (m * OpenShiftManager ) resolveClusterType (ctx context.Context ) {
105
95
if IsOpenShiftCluster (ctx , m .client , m .cfg ) {
106
- m .ClusterType = ClusterTypeOpenshift
96
+ m .ClusterType = conf . ClusterTypeOpenShift
107
97
} else {
108
- m .ClusterType = ClusterTypeDefault
98
+ m .ClusterType = conf . ClusterTypeDefault
109
99
}
110
100
}
111
101
@@ -657,24 +647,24 @@ func IsOpenShiftCluster(ctx context.Context,
657
647
Name : cfg .PodName ,
658
648
}
659
649
clusterType , err := resolveClusterTypeByPod (ctx , reader , key )
660
- return (err == nil ) && (clusterType == ClusterTypeOpenshift )
650
+ return (err == nil ) && (clusterType == conf . ClusterTypeOpenShift )
661
651
}
662
652
663
653
// resolveClusterTypeByPod finds the kind of K8s cluster via annotation of one
664
654
// of its running pods.
665
655
func resolveClusterTypeByPod (ctx context.Context ,
666
656
reader rtclient.Reader ,
667
- podKey rtclient.ObjectKey ) (ClusterType , error ) {
657
+ podKey rtclient.ObjectKey ) (string , error ) {
668
658
pod , err := getPod (ctx , reader , podKey )
669
659
if err != nil {
670
- return ClusterTypeDefault , err
660
+ return conf . ClusterTypeDefault , err
671
661
}
672
662
for key := range pod .Annotations {
673
- if strings .Contains (key , ClusterTypeOpenshift ) {
674
- return ClusterTypeOpenshift , nil
663
+ if strings .Contains (key , conf . ClusterTypeOpenShift ) {
664
+ return conf . ClusterTypeOpenShift , nil
675
665
}
676
666
}
677
- return ClusterTypeDefault , nil
667
+ return conf . ClusterTypeDefault , nil
678
668
}
679
669
680
670
func getPod (ctx context.Context ,
0 commit comments