Skip to content

Commit

Permalink
feat: exclude node by label (#167)
Browse files Browse the repository at this point in the history
Signed-off-by: chenk <[email protected]>
  • Loading branch information
chen-keinan authored May 24, 2023
1 parent c6bc37a commit f725fa7
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pkg/trivyk8s/trivyk8s.go
Original file line number Diff line number Diff line change
Expand Up @@ -292,11 +292,11 @@ func isNodeStatusUnknown(resource unstructured.Unstructured) bool {
}

func ignoreNodeByLabel(resource *artifacts.Artifact, ignoreLabels map[string]string) bool {

var matchingLabels int
for key, val := range ignoreLabels {
if lVal, ok := resource.Labels[key]; !ok || lVal != val {
return false
if lVal, ok := resource.Labels[key]; ok && lVal == val {
matchingLabels++
}
}
return true
return matchingLabels == len(ignoreLabels)
}

0 comments on commit f725fa7

Please sign in to comment.