From 170fe810756e77deece51cfed94d33248a735ba8 Mon Sep 17 00:00:00 2001 From: Eguzki Astiz Lezaun Date: Thu, 16 Nov 2023 23:02:49 +0100 Subject: [PATCH] authpolicy controller watches authconfig --- controllers/authpolicy_authconfig.go | 5 +++++ controllers/authpolicy_controller.go | 2 ++ 2 files changed, 7 insertions(+) diff --git a/controllers/authpolicy_authconfig.go b/controllers/authpolicy_authconfig.go index 478ae54bd..f244f8356 100644 --- a/controllers/authpolicy_authconfig.go +++ b/controllers/authpolicy_authconfig.go @@ -29,6 +29,11 @@ func (r *AuthPolicyReconciler) reconcileAuthConfigs(ctx context.Context, ap *api return err } + err = r.SetOwnerReference(ap, authConfig) + if err != nil { + return err + } + err = r.ReconcileResource(ctx, &authorinoapi.AuthConfig{}, authConfig, alwaysUpdateAuthConfig) if err != nil && !apierrors.IsAlreadyExists(err) { logger.Error(err, "ReconcileResource failed to create/update AuthConfig resource") diff --git a/controllers/authpolicy_controller.go b/controllers/authpolicy_controller.go index 490ab653f..2e21b454d 100644 --- a/controllers/authpolicy_controller.go +++ b/controllers/authpolicy_controller.go @@ -12,6 +12,7 @@ import ( "sigs.k8s.io/controller-runtime/pkg/handler" gatewayapiv1 "sigs.k8s.io/gateway-api/apis/v1" + authorinoapi "github.com/kuadrant/authorino/api/v1beta2" api "github.com/kuadrant/kuadrant-operator/api/v1beta2" "github.com/kuadrant/kuadrant-operator/pkg/common" "github.com/kuadrant/kuadrant-operator/pkg/reconcilers" @@ -226,6 +227,7 @@ func (r *AuthPolicyReconciler) SetupWithManager(mgr ctrl.Manager) error { return ctrl.NewControllerManagedBy(mgr). For(&api.AuthPolicy{}). + Owns(&authorinoapi.AuthConfig{}). Watches( &gatewayapiv1.HTTPRoute{}, handler.EnqueueRequestsFromMapFunc(httpRouteEventMapper.MapToAuthPolicy),