Example #1
0
func TestPodSpecNodeSelectorUpdateDisallowed(t *testing.T) {
	oldPod := &kapi.Pod{
		ObjectMeta: kapi.ObjectMeta{
			ResourceVersion: "1",
		},
		Spec: kapi.PodSpec{
			NodeSelector: map[string]string{
				"foo": "bar",
			},
		},
	}

	if errs := validation.ValidatePodUpdate(oldPod, oldPod); len(errs) != 0 {
		t.Fatal("expected no errors")
	}

	newPod := *oldPod
	// use a new map so it doesn't change oldPod's map too
	newPod.Spec.NodeSelector = map[string]string{"foo": "other"}

	errs := validation.ValidatePodUpdate(&newPod, oldPod)
	if len(errs) == 0 {
		t.Fatal("expected at least 1 error")
	}
}
Example #2
0
// ValidateUpdate is the default update validation for an end user.
func (podStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) utilvalidation.ErrorList {
	errorList := validation.ValidatePod(obj.(*api.Pod))
	return append(errorList, validation.ValidatePodUpdate(obj.(*api.Pod), old.(*api.Pod))...)
}
Example #3
0
// ValidateUpdate is the default update validation for an end user.
func (podStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime.Object) field.ErrorList {
	errorList := validation.ValidatePod(obj.(*api.Pod))
	return append(errorList, validation.ValidatePodUpdate(obj.(*api.Pod), old.(*api.Pod))...)
}