Skip to content

Commit c810d8d

Browse files
🐛 Fix HasResource pkg method to properly stop when a match is found (#4190)
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
1 parent 9f80d59 commit c810d8d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

pkg/config/v3/config.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,13 +160,15 @@ func (c Cfg) ResourcesLength() int {
160160

161161
// HasResource implements config.Config
162162
func (c Cfg) HasResource(gvk resource.GVK) bool {
163+
found := false
163164
for _, res := range c.Resources {
164165
if gvk.IsEqualTo(res.GVK) {
165-
return true
166+
found = true
167+
break
166168
}
167169
}
168170

169-
return false
171+
return found
170172
}
171173

172174
// GetResource implements config.Config

0 commit comments

Comments
 (0)