Skip to content

Commit

Permalink
♻️ Clean up label query logic
Browse files Browse the repository at this point in the history
  • Loading branch information
gabe565 committed Apr 21, 2022
1 parent 5ff604a commit 9742529
Showing 1 changed file with 4 additions and 13 deletions.
17 changes: 4 additions & 13 deletions internal/kubernetes/label_query_and.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,25 +9,16 @@ type LabelQueryAnd []LabelQuery

func (queries LabelQueryAnd) Matches(pod v1.Pod) bool {
for _, query := range queries {
if query.Matches(pod) {
return true
if !query.Matches(pod) {
return false
}
}
return false
return true
}

func (queries LabelQueryAnd) FindPods(list *v1.PodList) (pods []v1.Pod, err error) {
for _, pod := range list.Items {
var match bool
for _, query := range queries {
if query.Matches(pod) {
match = true
} else {
match = false
break
}
}
if match {
if queries.Matches(pod) {
pods = append(pods, pod)
}
}
Expand Down

0 comments on commit 9742529

Please sign in to comment.