From c810d8dd5d1f2ceba715832fb355959fba142d57 Mon Sep 17 00:00:00 2001 From: Camila Macedo <7708031+camilamacedo86@users.noreply.github.com> Date: Mon, 23 Sep 2024 08:31:29 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20HasResource=20pkg=20method?= =?UTF-8?q?=20to=20properly=20stop=20when=20a=20match=20is=20found=20(#419?= =?UTF-8?q?0)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fix HasResource method to properly stop when a match is found - Updated the HasResource method to correctly stop the iteration when a matching GVK is found. - Replaced the immediate return inside the loop with a boolean flag and a break statement to ensure the function exits early when a resource is found. - This resolves the issue where the method was not stopping as expected after finding a matching resource --- pkg/config/v3/config.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/pkg/config/v3/config.go b/pkg/config/v3/config.go index a3420bb3e64..0e51c1e3fe9 100644 --- a/pkg/config/v3/config.go +++ b/pkg/config/v3/config.go @@ -160,13 +160,15 @@ func (c Cfg) ResourcesLength() int { // HasResource implements config.Config func (c Cfg) HasResource(gvk resource.GVK) bool { + found := false for _, res := range c.Resources { if gvk.IsEqualTo(res.GVK) { - return true + found = true + break } } - return false + return found } // GetResource implements config.Config