From a2537785565869fcce191f2e2dfda927c4fd0281 Mon Sep 17 00:00:00 2001 From: BrunoTarijon Date: Wed, 31 Jul 2024 14:15:18 -0300 Subject: [PATCH] fix(controller): Get the right resourceName for traefik.io.Fixes #3615 Signed-off-by: BrunoTarijon --- rollout/trafficrouting/traefik/traefik.go | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/rollout/trafficrouting/traefik/traefik.go b/rollout/trafficrouting/traefik/traefik.go index 8b5cfb7312..3782ee824e 100644 --- a/rollout/trafficrouting/traefik/traefik.go +++ b/rollout/trafficrouting/traefik/traefik.go @@ -23,12 +23,6 @@ const Type = "Traefik" const traefikServices = "traefikservices" const TraefikServiceUpdateError = "TraefikServiceUpdateError" -var ( - apiGroupToResource = map[string]string{ - defaults.GetTraefikAPIGroup(): traefikServices, - } -) - type ReconcilerConfig struct { Rollout *v1alpha1.Rollout Client ClientInterface @@ -41,6 +35,13 @@ type Reconciler struct { Recorder record.EventRecorder } +func apiGroupToResource(group string) string { + apiGroupToResource := map[string]string{ + defaults.GetTraefikAPIGroup(): traefikServices, + } + return apiGroupToResource[group] +} + func (r *Reconciler) sendWarningEvent(id, msg string) { r.sendEvent(corev1.EventTypeWarning, id, msg) } @@ -71,7 +72,8 @@ func GetMappingGVR() schema.GroupVersionResource { group := defaults.GetTraefikAPIGroup() parts := strings.Split(defaults.GetTraefikVersion(), "/") version := parts[len(parts)-1] - resourceName := apiGroupToResource[group] + resourceName := apiGroupToResource(group) + return schema.GroupVersionResource{ Group: group, Version: version,