loop over communication sis now outside loop over namespaces.

This commit is contained in:
Erik Brakkee 2025-01-12 16:32:20 +01:00
parent ea6eb4e9ae
commit a640b726bf

View File

@ -76,30 +76,27 @@ func validate(files []string, options *Options) error {
} }
} }
} }
}
for _, communication := range config.Communications { for _, communication := range config.Communications {
if len(communication.Ports) == 0 { if len(communication.Ports) == 0 {
continue
}
for _, applicationName := range communication.To {
application, _, _ := config.GetApplication(applicationName)
if application == nil {
continue continue
} }
for _, applicationName := range communication.To { for _, port := range communication.Ports {
application, _, _ := config.GetApplication(applicationName) pods := FindPods(application, clientset)
if application == nil { for _, pod := range pods {
continue if !HasPort(pod, port) {
} LogValidationMsg(Error, "communication %v -> %v: port %v is not configured in pod %s/%s",
for _, port := range communication.Ports { communication.From, communication.To, port, pod.Namespace, pod.Name)
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 return nil
} }