Skip to content

Commit 87974f0

Browse files
changed the predicate function checks into a function
1 parent c6e2ad0 commit 87974f0

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

pkg/controller/configmap_ca_injector/controller.go

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -60,19 +60,16 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
6060
//"config.openshift.io/inject-trusted-cabundle" annotation
6161
pred := predicate.Funcs{
6262
UpdateFunc: func(e event.UpdateEvent) bool {
63-
return e.MetaNew.GetAnnotations()[names.TRUST_BUNDLE_CONFIGMAP_ANNOTATION] == "true" ||
64-
(e.MetaNew.GetName() == names.TRUST_BUNDLE_CONFIGMAP && e.MetaNew.GetNamespace() == names.TRUST_BUNDLE_CONFIGMAP_NS)
63+
return shouldUpdateConfigMaps(e.MetaNew)
6564
},
6665
DeleteFunc: func(e event.DeleteEvent) bool {
6766
return false
6867
},
6968
CreateFunc: func(e event.CreateEvent) bool {
70-
return e.Meta.GetAnnotations()[names.TRUST_BUNDLE_CONFIGMAP_ANNOTATION] == "true" ||
71-
(e.Meta.GetName() == names.TRUST_BUNDLE_CONFIGMAP && e.Meta.GetNamespace() == names.TRUST_BUNDLE_CONFIGMAP_NS)
69+
return shouldUpdateConfigMaps(e.Meta)
7270
},
7371
GenericFunc: func(e event.GenericEvent) bool {
74-
return e.Meta.GetAnnotations()[names.TRUST_BUNDLE_CONFIGMAP_ANNOTATION] == "true" ||
75-
(e.Meta.GetName() == names.TRUST_BUNDLE_CONFIGMAP && e.Meta.GetNamespace() == names.TRUST_BUNDLE_CONFIGMAP_NS)
72+
return shouldUpdateConfigMaps(e.Meta)
7673
},
7774
}
7875

@@ -178,3 +175,8 @@ func (r *ReconcileConfigMapInjector) validateTrustBundleConfigMap(cfgMap *corev1
178175

179176
return bundleData, nil
180177
}
178+
179+
func shouldUpdateConfigMaps(meta metav1.Object) bool {
180+
return meta.GetAnnotations()[names.TRUST_BUNDLE_CONFIGMAP_ANNOTATION] == "true" ||
181+
(meta.GetName() == names.TRUST_BUNDLE_CONFIGMAP && meta.GetNamespace() == names.TRUST_BUNDLE_CONFIGMAP_NS)
182+
}

0 commit comments

Comments
 (0)