mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Merge pull request #3660 from dchen1107/image
Using switch in validatePullPolicyWithDefault
This commit is contained in:
		@@ -266,8 +266,9 @@ func validateLifecycle(lifecycle *api.Lifecycle) errs.ValidationErrorList {
 | 
			
		||||
func validatePullPolicyWithDefault(ctr *api.Container) errs.ValidationErrorList {
 | 
			
		||||
	allErrors := errs.ValidationErrorList{}
 | 
			
		||||
 | 
			
		||||
	switch ctr.ImagePullPolicy {
 | 
			
		||||
	case "":
 | 
			
		||||
		// TODO(dchen1107): Move ParseImageName code to pkg/util
 | 
			
		||||
	if len(ctr.ImagePullPolicy) == 0 {
 | 
			
		||||
		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))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user