From bd75dfd4bb915208cb38b0cebd443f27fa2520ad Mon Sep 17 00:00:00 2001 From: Brendan Shephard Date: Mon, 28 Oct 2024 15:40:38 +1000 Subject: [PATCH] Index the customServiceConfigSecrets for use in the Secret lookup This change ensures the customServiceConfigSecrets value is indexed for when we need to use it in the FindObjectsForSrc function Signed-off-by: Brendan Shephard --- controllers/heat_controller.go | 12 ++++++++++++ controllers/heatapi_controller.go | 12 ++++++++++++ controllers/heatcfnapi_controller.go | 12 ++++++++++++ controllers/heatengine_controller.go | 12 ++++++++++++ 4 files changed, 48 insertions(+) diff --git a/controllers/heat_controller.go b/controllers/heat_controller.go index a73c6ac7..a9e13b56 100644 --- a/controllers/heat_controller.go +++ b/controllers/heat_controller.go @@ -225,6 +225,18 @@ func (r *HeatReconciler) SetupWithManager(mgr ctrl.Manager) error { return err } + // index customServiceConfigSecrets + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &heatv1beta1.Heat{}, customServiceConfigField, func(rawObj client.Object) []string { + // Extract the secret name from the spec, if one is provided + cr := rawObj.(*heatv1beta1.Heat) + if cr.Spec.CustomServiceConfigSecrets == nil { + return nil + } + return cr.Spec.CustomServiceConfigSecrets + }); err != nil { + return err + } + memcachedFn := func(_ context.Context, o client.Object) []reconcile.Request { result := []reconcile.Request{} diff --git a/controllers/heatapi_controller.go b/controllers/heatapi_controller.go index bb8d138d..aab599a2 100644 --- a/controllers/heatapi_controller.go +++ b/controllers/heatapi_controller.go @@ -225,6 +225,18 @@ func (r *HeatAPIReconciler) SetupWithManager(mgr ctrl.Manager) error { return err } + // index customServiceConfigSecrets + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &heatv1beta1.HeatAPI{}, customServiceConfigField, func(rawObj client.Object) []string { + // Extract the secret name from the spec, if one is provided + cr := rawObj.(*heatv1beta1.HeatAPI) + if cr.Spec.CustomServiceConfigSecrets == nil { + return nil + } + return cr.Spec.CustomServiceConfigSecrets + }); err != nil { + return err + } + configMapFn := func(_ context.Context, o client.Object) []reconcile.Request { result := []reconcile.Request{} diff --git a/controllers/heatcfnapi_controller.go b/controllers/heatcfnapi_controller.go index 1b5d6cb1..b5c495f2 100644 --- a/controllers/heatcfnapi_controller.go +++ b/controllers/heatcfnapi_controller.go @@ -227,6 +227,18 @@ func (r *HeatCfnAPIReconciler) SetupWithManager(mgr ctrl.Manager) error { return err } + // index customServiceConfigSecrets + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &heatv1beta1.HeatCfnAPI{}, customServiceConfigField, func(rawObj client.Object) []string { + // Extract the secret name from the spec, if one is provided + cr := rawObj.(*heatv1beta1.HeatCfnAPI) + if cr.Spec.CustomServiceConfigSecrets == nil { + return nil + } + return cr.Spec.CustomServiceConfigSecrets + }); err != nil { + return err + } + configMapFn := func(_ context.Context, o client.Object) []reconcile.Request { result := []reconcile.Request{} diff --git a/controllers/heatengine_controller.go b/controllers/heatengine_controller.go index 1f125a46..2070d4e1 100644 --- a/controllers/heatengine_controller.go +++ b/controllers/heatengine_controller.go @@ -179,6 +179,18 @@ func (r *HeatEngineReconciler) SetupWithManager(mgr ctrl.Manager) error { return err } + // index customServiceConfigSecrets + if err := mgr.GetFieldIndexer().IndexField(context.Background(), &heatv1beta1.HeatEngine{}, customServiceConfigField, func(rawObj client.Object) []string { + // Extract the secret name from the spec, if one is provided + cr := rawObj.(*heatv1beta1.HeatEngine) + if cr.Spec.CustomServiceConfigSecrets == nil { + return nil + } + return cr.Spec.CustomServiceConfigSecrets + }); err != nil { + return err + } + configMapFn := func(_ context.Context, o client.Object) []reconcile.Request { result := []reconcile.Request{}