Skip to content

Commit

Permalink
changed the predicate function checks into a function
Browse files Browse the repository at this point in the history
  • Loading branch information
JacobTanenbaum committed Aug 8, 2019
1 parent c6e2ad0 commit 87974f0
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions pkg/controller/configmap_ca_injector/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,19 +60,16 @@ func add(mgr manager.Manager, r reconcile.Reconciler) error {
//"config.openshift.io/inject-trusted-cabundle" annotation
pred := predicate.Funcs{
UpdateFunc: func(e event.UpdateEvent) bool {
return e.MetaNew.GetAnnotations()[names.TRUST_BUNDLE_CONFIGMAP_ANNOTATION] == "true" ||
(e.MetaNew.GetName() == names.TRUST_BUNDLE_CONFIGMAP && e.MetaNew.GetNamespace() == names.TRUST_BUNDLE_CONFIGMAP_NS)
return shouldUpdateConfigMaps(e.MetaNew)
},
DeleteFunc: func(e event.DeleteEvent) bool {
return false
},
CreateFunc: func(e event.CreateEvent) bool {
return e.Meta.GetAnnotations()[names.TRUST_BUNDLE_CONFIGMAP_ANNOTATION] == "true" ||
(e.Meta.GetName() == names.TRUST_BUNDLE_CONFIGMAP && e.Meta.GetNamespace() == names.TRUST_BUNDLE_CONFIGMAP_NS)
return shouldUpdateConfigMaps(e.Meta)
},
GenericFunc: func(e event.GenericEvent) bool {
return e.Meta.GetAnnotations()[names.TRUST_BUNDLE_CONFIGMAP_ANNOTATION] == "true" ||
(e.Meta.GetName() == names.TRUST_BUNDLE_CONFIGMAP && e.Meta.GetNamespace() == names.TRUST_BUNDLE_CONFIGMAP_NS)
return shouldUpdateConfigMaps(e.Meta)
},
}

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

return bundleData, nil
}

func shouldUpdateConfigMaps(meta metav1.Object) bool {
return meta.GetAnnotations()[names.TRUST_BUNDLE_CONFIGMAP_ANNOTATION] == "true" ||
(meta.GetName() == names.TRUST_BUNDLE_CONFIGMAP && meta.GetNamespace() == names.TRUST_BUNDLE_CONFIGMAP_NS)
}

0 comments on commit 87974f0

Please sign in to comment.