From a640b726bfb7a1c3d6c30ddf4197c3cb6382665b Mon Sep 17 00:00:00 2001 From: Erik Brakkee Date: Sun, 12 Jan 2025 16:32:20 +0100 Subject: [PATCH] loop over communication sis now outside loop over namespaces. --- cmd/policygen/configvalidator.go | 33 +++++++++++++++----------------- 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/cmd/policygen/configvalidator.go b/cmd/policygen/configvalidator.go index c5004c3..360059f 100644 --- a/cmd/policygen/configvalidator.go +++ b/cmd/policygen/configvalidator.go @@ -76,30 +76,27 @@ func validate(files []string, options *Options) error { } } } - - for _, communication := range config.Communications { - if len(communication.Ports) == 0 { + } + for _, communication := range config.Communications { + if len(communication.Ports) == 0 { + continue + } + for _, applicationName := range communication.To { + application, _, _ := config.GetApplication(applicationName) + if application == nil { continue } - for _, applicationName := range communication.To { - application, _, _ := config.GetApplication(applicationName) - if application == nil { - continue - } - for _, port := range communication.Ports { - pods := FindPods(application, clientset) - for _, pod := range pods { - if !HasPort(pod, port) { - LogValidationMsg(Error, "communication %v -> %v: port %v is not configured in pod %s/%s", - communication.From, communication.To, port, pod.Namespace, pod.Name) - } + for _, port := range communication.Ports { + pods := FindPods(application, clientset) + for _, pod := range pods { + if !HasPort(pod, port) { + LogValidationMsg(Error, "communication %v -> %v: port %v is not configured in pod %s/%s", + communication.From, communication.To, port, pod.Namespace, pod.Name) } - } + } - } - } return nil }