44 "context"
55 "errors"
66 "fmt"
7+ "regexp"
8+ "strings"
9+
710 . "github.com/onsi/ginkgo"
811 . "github.com/onsi/gomega"
912 "github.com/operator-framework/operator-lifecycle-manager/pkg/controller/registry/resolver/runtime_constraints"
@@ -13,24 +16,22 @@ import (
1316 corev1 "k8s.io/api/core/v1"
1417 k8serrors "k8s.io/apimachinery/pkg/api/errors"
1518 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
16- "regexp"
1719 k8scontrollerclient "sigs.k8s.io/controller-runtime/pkg/client"
18- "strings"
1920)
2021
2122const (
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
2829)
2930
3031var (
3132 olmOperatorKey = k8scontrollerclient.ObjectKey {
3233 Namespace : defaultOlmNamespace ,
33- Name : olmOperatorName ,
34+ Name : olmOperatorName ,
3435 }
3536)
3637
@@ -85,7 +86,7 @@ func mustDeployRuntimeConstraintsConfigMap(kubeClient k8scontrollerclient.Client
8586 isImmutable := true
8687 configMap := & corev1.ConfigMap {
8788 ObjectMeta : metav1.ObjectMeta {
88- Name : runtimeConstraintsConfigMapName ,
89+ Name : runtimeConstraintsConfigMapName ,
8990 Namespace : defaultOlmNamespace ,
9091 },
9192 Immutable : & isImmutable ,
@@ -103,7 +104,7 @@ func mustDeployRuntimeConstraintsConfigMap(kubeClient k8scontrollerclient.Client
103104func mustUndeployRuntimeConstraintsConfigMap (kubeClient k8scontrollerclient.Client ) {
104105 if err := kubeClient .Delete (context .TODO (), & corev1.ConfigMap {
105106 ObjectMeta : metav1.ObjectMeta {
106- Name : "runtime-constraints" ,
107+ Name : "runtime-constraints" ,
107108 Namespace : "operator-lifecycle-manager" ,
108109 },
109110 }); err != nil {
@@ -114,7 +115,7 @@ func mustUndeployRuntimeConstraintsConfigMap(kubeClient k8scontrollerclient.Clie
114115 Eventually (func () bool {
115116 configMap := & corev1.ConfigMap {}
116117 err := kubeClient .Get (context .TODO (), k8scontrollerclient.ObjectKey {
117- Name : runtimeConstraintsConfigMapName ,
118+ Name : runtimeConstraintsConfigMapName ,
118119 Namespace : defaultOlmNamespace ,
119120 }, configMap )
120121 return k8serrors .IsNotFound (err )
@@ -145,15 +146,15 @@ func mustPatchOlmDeployment(kubeClient k8scontrollerclient.Client) {
145146
146147 mountPath := "/constraints"
147148 newVolumeMount := corev1.VolumeMount {
148- Name : runtimeConstraintsVolumeMountName ,
149+ Name : runtimeConstraintsVolumeMountName ,
149150 MountPath : mountPath ,
150- ReadOnly : true ,
151+ ReadOnly : true ,
151152 }
152153
153154 olmDeployment .Spec .Template .Spec .Volumes = append (volumes , newVolume )
154155 olmDeployment .Spec .Template .Spec .Containers [olmContainerIndex ].VolumeMounts = append (olmContainer .VolumeMounts , newVolumeMount )
155156 olmDeployment .Spec .Template .Spec .Containers [olmContainerIndex ].Env = append (olmContainer .Env , corev1.EnvVar {
156- Name : runtime_constraints .RuntimeConstraintEnvVarName ,
157+ Name : runtime_constraints .RuntimeConstraintEnvVarName ,
157158 Value : fmt .Sprintf ("/%s/%s" , mountPath , runtimeConstraintsFileName ),
158159 })
159160
@@ -215,7 +216,6 @@ func setupRuntimeConstraints(kubeClient k8scontrollerclient.Client) {
215216 mustPatchOlmDeployment (kubeClient )
216217}
217218
218-
219219func teardownRuntimeConstraints (kubeClient k8scontrollerclient.Client ) {
220220 mustUndeployRuntimeConstraintsConfigMap (kubeClient )
221221 mustUnpatchOlmDeployment (kubeClient )
0 commit comments