mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-09 03:57:41 +00:00
Merge pull request #3660 from dchen1107/image
Using switch in validatePullPolicyWithDefault
This commit is contained in:
commit
c729f345f0
@ -266,8 +266,9 @@ func validateLifecycle(lifecycle *api.Lifecycle) errs.ValidationErrorList {
|
||||
func validatePullPolicyWithDefault(ctr *api.Container) errs.ValidationErrorList {
|
||||
allErrors := errs.ValidationErrorList{}
|
||||
|
||||
// TODO(dchen1107): Move ParseImageName code to pkg/util
|
||||
if len(ctr.ImagePullPolicy) == 0 {
|
||||
switch ctr.ImagePullPolicy {
|
||||
case "":
|
||||
// TODO(dchen1107): Move ParseImageName code to pkg/util
|
||||
parts := strings.Split(ctr.Image, ":")
|
||||
// Check image tag
|
||||
if parts[len(parts)-1] == "latest" {
|
||||
@ -275,10 +276,9 @@ func validatePullPolicyWithDefault(ctr *api.Container) errs.ValidationErrorList
|
||||
} else {
|
||||
ctr.ImagePullPolicy = api.PullIfNotPresent
|
||||
}
|
||||
}
|
||||
if ctr.ImagePullPolicy != api.PullAlways &&
|
||||
ctr.ImagePullPolicy != api.PullIfNotPresent &&
|
||||
ctr.ImagePullPolicy != api.PullNever {
|
||||
case api.PullAlways, api.PullIfNotPresent, api.PullNever:
|
||||
break
|
||||
default:
|
||||
allErrors = append(allErrors, errs.NewFieldNotSupported("", ctr.ImagePullPolicy))
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user