mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-08 19:47:56 +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 {
|
func validatePullPolicyWithDefault(ctr *api.Container) errs.ValidationErrorList {
|
||||||
allErrors := errs.ValidationErrorList{}
|
allErrors := errs.ValidationErrorList{}
|
||||||
|
|
||||||
|
switch ctr.ImagePullPolicy {
|
||||||
|
case "":
|
||||||
// TODO(dchen1107): Move ParseImageName code to pkg/util
|
// TODO(dchen1107): Move ParseImageName code to pkg/util
|
||||||
if len(ctr.ImagePullPolicy) == 0 {
|
|
||||||
parts := strings.Split(ctr.Image, ":")
|
parts := strings.Split(ctr.Image, ":")
|
||||||
// Check image tag
|
// Check image tag
|
||||||
if parts[len(parts)-1] == "latest" {
|
if parts[len(parts)-1] == "latest" {
|
||||||
@ -275,10 +276,9 @@ func validatePullPolicyWithDefault(ctr *api.Container) errs.ValidationErrorList
|
|||||||
} else {
|
} else {
|
||||||
ctr.ImagePullPolicy = api.PullIfNotPresent
|
ctr.ImagePullPolicy = api.PullIfNotPresent
|
||||||
}
|
}
|
||||||
}
|
case api.PullAlways, api.PullIfNotPresent, api.PullNever:
|
||||||
if ctr.ImagePullPolicy != api.PullAlways &&
|
break
|
||||||
ctr.ImagePullPolicy != api.PullIfNotPresent &&
|
default:
|
||||||
ctr.ImagePullPolicy != api.PullNever {
|
|
||||||
allErrors = append(allErrors, errs.NewFieldNotSupported("", ctr.ImagePullPolicy))
|
allErrors = append(allErrors, errs.NewFieldNotSupported("", ctr.ImagePullPolicy))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user