Create helpers for iterating containers in a pod

This commit is contained in:
Lee Verberne
2019-06-14 15:20:16 +00:00
parent 4683054ff6
commit ee821e2a04
15 changed files with 467 additions and 271 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 (