Skip to content

Commit

Permalink
fix linter service port check for native sidecars
Browse files Browse the repository at this point in the history
  • Loading branch information
eminugurkenar committed Oct 22, 2024
1 parent 13f3b9c commit 821ffbb
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion internal/lint/svc.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,15 @@ func checkServicePort(port v1.ServicePort, ports map[string]string) bool {

// PortsForPod computes a port map for a given pod.
func portsForPod(pod *v1.Pod, ports map[string]string) {
for _, co := range pod.Spec.Containers {
cos := append([]v1.Container{}, pod.Spec.Containers...)

for _, ico := range pod.Spec.InitContainers {
if ico.RestartPolicy != nil && *ico.RestartPolicy == v1.ContainerRestartPolicyAlways {
cos = append(cos, ico)
}
}

for _, co := range cos {
for _, p := range co.Ports {
ports[portFQN(p.Protocol, strconv.Itoa(int(p.ContainerPort)))] = co.Name
if p.Name != "" {
Expand Down

0 comments on commit 821ffbb

Please sign in to comment.