Skip to content

Commit

Permalink
fix: defer to service analyser when selectors are missing (#652)
Browse files Browse the repository at this point in the history
Signed-off-by: Aris Boutselis <arisboutselis08@gmail.com>
Co-authored-by: Aris Boutselis <arisboutselis08@gmail.com>
Co-authored-by: Alex Jones <alexsimonjones@gmail.com>
  • Loading branch information
3 people authored Sep 14, 2023
1 parent 598ef22 commit 6c5a062
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
4 changes: 4 additions & 0 deletions pkg/analyzer/mutating_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ func (MutatingWebhookAnalyzer) Analyze(a common.Analyzer) ([]common.Result, erro
continue
}

// When Service selectors are empty we defer to service analyser
if len(service.Spec.Selector) == 0 {
continue
}
// Get pods within service
pods, err := a.Client.GetClient().CoreV1().Pods(svc.Namespace).List(context.Background(), v1.ListOptions{
LabelSelector: util.MapToString(service.Spec.Selector),
Expand Down
4 changes: 4 additions & 0 deletions pkg/analyzer/validating_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,10 @@ func (ValidatingWebhookAnalyzer) Analyze(a common.Analyzer) ([]common.Result, er
continue
}

// When Service selectors are empty we defer to service analyser
if len(service.Spec.Selector) == 0 {
continue
}
// Get pods within service
pods, err := a.Client.GetClient().CoreV1().Pods(svc.Namespace).List(context.Background(), v1.ListOptions{
LabelSelector: util.MapToString(service.Spec.Selector),
Expand Down

0 comments on commit 6c5a062

Please sign in to comment.