mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-09-25 20:29:56 +00:00
Merge pull request #79387 from tedyu/cont-helper-early
Restore early return for podSpecHasContainer
This commit is contained in:
@@ -65,8 +65,9 @@ func (a *AlwaysPullImages) Admit(attributes admission.Attributes, o admission.Ob
|
||||
return apierrors.NewBadRequest("Resource was marked with kind Pod but was unable to be converted")
|
||||
}
|
||||
|
||||
pods.VisitContainersWithPath(&pod.Spec, func(c *api.Container, _ *field.Path) {
|
||||
pods.VisitContainersWithPath(&pod.Spec, func(c *api.Container, _ *field.Path) bool {
|
||||
c.ImagePullPolicy = api.PullAlways
|
||||
return true
|
||||
})
|
||||
|
||||
return nil
|
||||
@@ -84,12 +85,13 @@ func (*AlwaysPullImages) Validate(attributes admission.Attributes, o admission.O
|
||||
}
|
||||
|
||||
var allErrs []error
|
||||
pods.VisitContainersWithPath(&pod.Spec, func(c *api.Container, p *field.Path) {
|
||||
pods.VisitContainersWithPath(&pod.Spec, func(c *api.Container, p *field.Path) bool {
|
||||
if c.ImagePullPolicy != api.PullAlways {
|
||||
allErrs = append(allErrs, admission.NewForbidden(attributes,
|
||||
field.NotSupported(p.Child("imagePullPolicy"), c.ImagePullPolicy, []string{string(api.PullAlways)}),
|
||||
))
|
||||
}
|
||||
return true
|
||||
})
|
||||
if len(allErrs) > 0 {
|
||||
return utilerrors.NewAggregate(allErrs)
|
||||
|
@@ -185,10 +185,11 @@ func safeToApplyPodPresetsOnPod(pod *api.Pod, podPresets []*settingsv1alpha1.Pod
|
||||
if _, err := mergeVolumes(pod.Spec.Volumes, podPresets); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
pods.VisitContainersWithPath(&pod.Spec, func(c *api.Container, _ *field.Path) {
|
||||
pods.VisitContainersWithPath(&pod.Spec, func(c *api.Container, _ *field.Path) bool {
|
||||
if err := safeToApplyPodPresetsOnContainer(c, podPresets); err != nil {
|
||||
errs = append(errs, err)
|
||||
}
|
||||
return true
|
||||
})
|
||||
|
||||
return utilerrors.NewAggregate(errs)
|
||||
|
Reference in New Issue
Block a user