Merge pull request #79176 from verb/debug-iterate-containers

Add helpers for iterating containers in a pod
This commit is contained in:
Kubernetes Prow Robot
2019-06-25 09:32:52 -07:00
committed by GitHub
22 changed files with 484 additions and 272 deletions

View File

@@ -3434,17 +3434,13 @@ func ValidateAppArmorPodAnnotations(annotations map[string]string, spec *core.Po
}
func podSpecHasContainer(spec *core.PodSpec, containerName string) bool {
for _, c := range spec.InitContainers {
var hasContainer bool
podshelper.VisitContainersWithPath(spec, func(c *core.Container, _ *field.Path) {
if c.Name == containerName {
return true
hasContainer = true
}
}
for _, c := range spec.Containers {
if c.Name == containerName {
return true
}
}
return false
})
return hasContainer
}
const (