mirror of
				https://github.com/optim-enterprises-bv/kubernetes.git
				synced 2025-11-04 04:08:16 +00:00 
			
		
		
		
	Minor cleanups.
- ValidateNoNewFinalizers: remove unused const - Mention that mutation of spec.initContainers[*].image field is allowed - Improve godoc comments - validation_test.go(expectPrefix): remove unused function
This commit is contained in:
		@@ -2447,8 +2447,8 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) field.ErrorList {
 | 
			
		||||
	specPath := field.NewPath("spec")
 | 
			
		||||
 | 
			
		||||
	// validate updateable fields:
 | 
			
		||||
	// 1.  containers[*].image
 | 
			
		||||
	// 2.  initContainers[*].image
 | 
			
		||||
	// 1.  spec.containers[*].image
 | 
			
		||||
	// 2.  spec.initContainers[*].image
 | 
			
		||||
	// 3.  spec.activeDeadlineSeconds
 | 
			
		||||
 | 
			
		||||
	containerErrs, stop := ValidateContainerUpdates(newPod.Spec.Containers, oldPod.Spec.Containers, specPath.Child("containers"))
 | 
			
		||||
@@ -2484,14 +2484,14 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) field.ErrorList {
 | 
			
		||||
 | 
			
		||||
	// handle updateable fields by munging those fields prior to deep equal comparison.
 | 
			
		||||
	mungedPod := *newPod
 | 
			
		||||
	// munge containers[*].image
 | 
			
		||||
	// munge spec.containers[*].image
 | 
			
		||||
	var newContainers []api.Container
 | 
			
		||||
	for ix, container := range mungedPod.Spec.Containers {
 | 
			
		||||
		container.Image = oldPod.Spec.Containers[ix].Image
 | 
			
		||||
		newContainers = append(newContainers, container)
 | 
			
		||||
	}
 | 
			
		||||
	mungedPod.Spec.Containers = newContainers
 | 
			
		||||
	// munge initContainers[*].image
 | 
			
		||||
	// munge spec.initContainers[*].image
 | 
			
		||||
	var newInitContainers []api.Container
 | 
			
		||||
	for ix, container := range mungedPod.Spec.InitContainers {
 | 
			
		||||
		container.Image = oldPod.Spec.InitContainers[ix].Image
 | 
			
		||||
@@ -2511,7 +2511,7 @@ func ValidatePodUpdate(newPod, oldPod *api.Pod) field.ErrorList {
 | 
			
		||||
 | 
			
		||||
	if !apiequality.Semantic.DeepEqual(mungedPod.Spec, oldPod.Spec) {
 | 
			
		||||
		//TODO: Pinpoint the specific field that causes the invalid error after we have strategic merge diff
 | 
			
		||||
		allErrs = append(allErrs, field.Forbidden(specPath, "pod updates may not change fields other than `containers[*].image` or `spec.activeDeadlineSeconds` or `spec.tolerations` (only additions to existing tolerations)"))
 | 
			
		||||
		allErrs = append(allErrs, field.Forbidden(specPath, "pod updates may not change fields other than `spec.containers[*].image`, `spec.initContainers[*].image`, `spec.activeDeadlineSeconds` or `spec.tolerations` (only additions to existing tolerations)"))
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	return allErrs
 | 
			
		||||
 
 | 
			
		||||
@@ -44,14 +44,6 @@ const (
 | 
			
		||||
	idErrMsg                = "a valid C identifier must"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func expectPrefix(t *testing.T, prefix string, errs field.ErrorList) {
 | 
			
		||||
	for i := range errs {
 | 
			
		||||
		if f, p := errs[i].Field, prefix; !strings.HasPrefix(f, p) {
 | 
			
		||||
			t.Errorf("expected prefix '%s' for field '%s' (%v)", p, f, errs[i])
 | 
			
		||||
		}
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func testVolume(name string, namespace string, spec api.PersistentVolumeSpec) *api.PersistentVolume {
 | 
			
		||||
	objMeta := metav1.ObjectMeta{Name: name}
 | 
			
		||||
	if namespace != "" {
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,7 @@ import (
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// mustRunAs implements the GroupStrategy interface
 | 
			
		||||
// runAsAny implements the GroupStrategy interface.
 | 
			
		||||
type runAsAny struct {
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -24,7 +24,7 @@ import (
 | 
			
		||||
	"k8s.io/kubernetes/pkg/api"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
// mustMatchPatterns implements the CapabilitiesStrategy interface
 | 
			
		||||
// mustMatchPatterns implements the SysctlsStrategy interface
 | 
			
		||||
type mustMatchPatterns struct {
 | 
			
		||||
	patterns []string
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -129,7 +129,7 @@ func GetVolumeFSType(v api.Volume) (extensions.FSType, error) {
 | 
			
		||||
	return "", fmt.Errorf("unknown volume type for volume: %#v", v)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// fsTypeToStringSet converts an FSType slice to a string set.
 | 
			
		||||
// FSTypeToStringSet converts an FSType slice to a string set.
 | 
			
		||||
func FSTypeToStringSet(fsTypes []extensions.FSType) sets.String {
 | 
			
		||||
	set := sets.NewString()
 | 
			
		||||
	for _, v := range fsTypes {
 | 
			
		||||
 
 | 
			
		||||
@@ -111,7 +111,6 @@ func ValidateFinalizerName(stringValue string, fldPath *field.Path) field.ErrorL
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func ValidateNoNewFinalizers(newFinalizers []string, oldFinalizers []string, fldPath *field.Path) field.ErrorList {
 | 
			
		||||
	const newFinalizersErrorMsg string = `no new finalizers can be added if the object is being deleted`
 | 
			
		||||
	allErrs := field.ErrorList{}
 | 
			
		||||
	extra := sets.NewString(newFinalizers...).Difference(sets.NewString(oldFinalizers...))
 | 
			
		||||
	if len(extra) != 0 {
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user