4
4
"context"
5
5
"errors"
6
6
"fmt"
7
+ "regexp"
8
+ "strings"
9
+
7
10
. "github.com/onsi/ginkgo"
8
11
. "github.com/onsi/gomega"
9
12
"github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/runtime_constraints"
@@ -13,24 +16,22 @@ import (
13
16
corev1 "k8s.io/api/core/v1"
14
17
k8serrors "k8s.io/apimachinery/pkg/api/errors"
15
18
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16
- "regexp"
17
19
k8scontrollerclient "sigs.k8s.io/controller-runtime/pkg/client"
18
- "strings"
19
20
)
20
21
21
22
const (
22
- runtimeConstraintsVolumeMountName = "runtime-constraints"
23
- runtimeConstraintsConfigMapName = "runtime-constraints"
24
- runtimeConstraintsFileName = "runtime_constraints.yaml"
25
- defaultOlmNamespace = "operator-lifecycle-manager"
26
- olmOperatorName = "olm-operator"
27
- olmContainerIndex = 0
23
+ runtimeConstraintsVolumeMountName = "runtime-constraints"
24
+ runtimeConstraintsConfigMapName = "runtime-constraints"
25
+ runtimeConstraintsFileName = "runtime_constraints.yaml"
26
+ defaultOlmNamespace = "operator-lifecycle-manager"
27
+ olmOperatorName = "olm-operator"
28
+ olmContainerIndex = 0
28
29
)
29
30
30
31
var (
31
32
olmOperatorKey = k8scontrollerclient.ObjectKey {
32
33
Namespace : defaultOlmNamespace ,
33
- Name : olmOperatorName ,
34
+ Name : olmOperatorName ,
34
35
}
35
36
)
36
37
@@ -85,7 +86,7 @@ func mustDeployRuntimeConstraintsConfigMap(kubeClient k8scontrollerclient.Client
85
86
isImmutable := true
86
87
configMap := & corev1.ConfigMap {
87
88
ObjectMeta : metav1.ObjectMeta {
88
- Name : runtimeConstraintsConfigMapName ,
89
+ Name : runtimeConstraintsConfigMapName ,
89
90
Namespace : defaultOlmNamespace ,
90
91
},
91
92
Immutable : & isImmutable ,
@@ -103,7 +104,7 @@ func mustDeployRuntimeConstraintsConfigMap(kubeClient k8scontrollerclient.Client
103
104
func mustUndeployRuntimeConstraintsConfigMap (kubeClient k8scontrollerclient.Client ) {
104
105
if err := kubeClient .Delete (context .TODO (), & corev1.ConfigMap {
105
106
ObjectMeta : metav1.ObjectMeta {
106
- Name : "runtime-constraints" ,
107
+ Name : "runtime-constraints" ,
107
108
Namespace : "operator-lifecycle-manager" ,
108
109
},
109
110
}); err != nil {
@@ -114,7 +115,7 @@ func mustUndeployRuntimeConstraintsConfigMap(kubeClient k8scontrollerclient.Clie
114
115
Eventually (func () bool {
115
116
configMap := & corev1.ConfigMap {}
116
117
err := kubeClient .Get (context .TODO (), k8scontrollerclient.ObjectKey {
117
- Name : runtimeConstraintsConfigMapName ,
118
+ Name : runtimeConstraintsConfigMapName ,
118
119
Namespace : defaultOlmNamespace ,
119
120
}, configMap )
120
121
return k8serrors .IsNotFound (err )
@@ -145,15 +146,15 @@ func mustPatchOlmDeployment(kubeClient k8scontrollerclient.Client) {
145
146
146
147
mountPath := "/constraints"
147
148
newVolumeMount := corev1.VolumeMount {
148
- Name : runtimeConstraintsVolumeMountName ,
149
+ Name : runtimeConstraintsVolumeMountName ,
149
150
MountPath : mountPath ,
150
- ReadOnly : true ,
151
+ ReadOnly : true ,
151
152
}
152
153
153
154
olmDeployment .Spec .Template .Spec .Volumes = append (volumes , newVolume )
154
155
olmDeployment .Spec .Template .Spec .Containers [olmContainerIndex ].VolumeMounts = append (olmContainer .VolumeMounts , newVolumeMount )
155
156
olmDeployment .Spec .Template .Spec .Containers [olmContainerIndex ].Env = append (olmContainer .Env , corev1.EnvVar {
156
- Name : runtime_constraints .RuntimeConstraintEnvVarName ,
157
+ Name : runtime_constraints .RuntimeConstraintEnvVarName ,
157
158
Value : fmt .Sprintf ("/%s/%s" , mountPath , runtimeConstraintsFileName ),
158
159
})
159
160
@@ -215,7 +216,6 @@ func setupRuntimeConstraints(kubeClient k8scontrollerclient.Client) {
215
216
mustPatchOlmDeployment (kubeClient )
216
217
}
217
218
218
-
219
219
func teardownRuntimeConstraints (kubeClient k8scontrollerclient.Client ) {
220
220
mustUndeployRuntimeConstraintsConfigMap (kubeClient )
221
221
mustUnpatchOlmDeployment (kubeClient )
0 commit comments