From 708db68ed14d0739e964937d46edf8ba8affabd9 Mon Sep 17 00:00:00 2001 From: Bruno Aumiller Tarijon <42080746+BrunoTarijon@users.noreply.github.com> Date: Thu, 1 Aug 2024 11:03:33 -0300 Subject: [PATCH] fix(controller): Get the right resourceName for traefik.io.Fixes #3615 (#3759) 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,