Skip to content

Commit

Permalink
πŸ› Fix HasResource pkg method to properly stop when a match is found (#…
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
camilamacedo86 authored Sep 23, 2024
1 parent 9f80d59 commit c810d8d
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pkg/config/v3/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit c810d8d

Please sign in to comment.