mirror of
https://github.com/optim-enterprises-bv/kubernetes.git
synced 2025-11-02 19:28: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 != "" {
|
||||
|
||||
Reference in New Issue
Block a user