Restore early return for podSpecHasContainer

This commit is contained in:
Ted Yu
2019-06-26 14:17:11 +08:00
committed by Ted Yu
parent e8738d665b
commit cf7c164ae3
6 changed files with 28 additions and 12 deletions

View File

@@ -3435,10 +3435,12 @@ func ValidateAppArmorPodAnnotations(annotations map[string]string, spec *core.Po
func podSpecHasContainer(spec *core.PodSpec, containerName string) bool {
var hasContainer bool
podshelper.VisitContainersWithPath(spec, func(c *core.Container, _ *field.Path) {
podshelper.VisitContainersWithPath(spec, func(c *core.Container, _ *field.Path) bool {
if c.Name == containerName {
hasContainer = true
return false
}
return true
})
return hasContainer
}