diff --git a/pkg/api/validation/validation.go b/pkg/api/validation/validation.go index 9563a7ce56..6dfeeb0c29 100644 --- a/pkg/api/validation/validation.go +++ b/pkg/api/validation/validation.go @@ -1225,6 +1225,7 @@ func validateFinalizerName(stringValue string) errs.ValidationErrorList { // ValidateNamespaceUpdate tests to make sure a namespace update can be applied. // newNamespace is updated with fields that cannot be changed +// TODO The syntax here is the reverse of the (old, new) pattern in most other validation. Fix this. func ValidateNamespaceUpdate(newNamespace *api.Namespace, oldNamespace *api.Namespace) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, ValidateObjectMetaUpdate(&oldNamespace.ObjectMeta, &newNamespace.ObjectMeta).Prefix("metadata")...) diff --git a/pkg/registry/controller/rest.go b/pkg/registry/controller/rest.go index ffe25c865b..cf8357f2c0 100644 --- a/pkg/registry/controller/rest.go +++ b/pkg/registry/controller/rest.go @@ -71,7 +71,9 @@ func (rcStrategy) AllowCreateOnUpdate() bool { // ValidateUpdate is the default update validation for an end user. func (rcStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidateReplicationControllerUpdate(old.(*api.ReplicationController), obj.(*api.ReplicationController)) + validationErrorList := validation.ValidateReplicationController(obj.(*api.ReplicationController)) + updateErrorList := validation.ValidateReplicationControllerUpdate(old.(*api.ReplicationController), obj.(*api.ReplicationController)) + return append(validationErrorList, updateErrorList...) } // ControllerToSelectableFields returns a label set that represents the object. diff --git a/pkg/registry/endpoint/rest.go b/pkg/registry/endpoint/rest.go index 08f799cb9c..ae96bdd206 100644 --- a/pkg/registry/endpoint/rest.go +++ b/pkg/registry/endpoint/rest.go @@ -69,7 +69,8 @@ func (endpointsStrategy) AllowCreateOnUpdate() bool { // ValidateUpdate is the default update validation for an end user. func (endpointsStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidateEndpointsUpdate(old.(*api.Endpoints), obj.(*api.Endpoints)) + errorList := validation.ValidateEndpoints(obj.(*api.Endpoints)) + return append(errorList, validation.ValidateEndpointsUpdate(old.(*api.Endpoints), obj.(*api.Endpoints))...) } // MatchEndpoints returns a generic matcher for a given label and field selector. diff --git a/pkg/registry/minion/rest.go b/pkg/registry/minion/rest.go index 38df7bfba2..f17ccde149 100644 --- a/pkg/registry/minion/rest.go +++ b/pkg/registry/minion/rest.go @@ -74,7 +74,8 @@ func (nodeStrategy) Validate(ctx api.Context, obj runtime.Object) fielderrors.Va // ValidateUpdate is the default update validation for an end user. func (nodeStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidateMinionUpdate(old.(*api.Node), obj.(*api.Node)) + errorList := validation.ValidateMinion(obj.(*api.Node)) + return append(errorList, validation.ValidateMinionUpdate(old.(*api.Node), obj.(*api.Node))...) } // ResourceGetter is an interface for retrieving resources by ResourceLocation. diff --git a/pkg/registry/namespace/rest.go b/pkg/registry/namespace/rest.go index 07acc72501..cdb1deb095 100644 --- a/pkg/registry/namespace/rest.go +++ b/pkg/registry/namespace/rest.go @@ -89,7 +89,8 @@ func (namespaceStrategy) AllowCreateOnUpdate() bool { // ValidateUpdate is the default update validation for an end user. func (namespaceStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidateNamespaceUpdate(obj.(*api.Namespace), old.(*api.Namespace)) + errorList := validation.ValidateNamespace(obj.(*api.Namespace)) + return append(errorList, validation.ValidateNamespaceUpdate(obj.(*api.Namespace), old.(*api.Namespace))...) } type namespaceStatusStrategy struct { diff --git a/pkg/registry/persistentvolume/rest.go b/pkg/registry/persistentvolume/rest.go index fd17bae5ba..5a26f3523e 100644 --- a/pkg/registry/persistentvolume/rest.go +++ b/pkg/registry/persistentvolume/rest.go @@ -65,7 +65,8 @@ func (persistentvolumeStrategy) PrepareForUpdate(obj, old runtime.Object) { } func (persistentvolumeStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidatePersistentVolumeUpdate(obj.(*api.PersistentVolume), old.(*api.PersistentVolume)) + errorList := validation.ValidatePersistentVolume(obj.(*api.PersistentVolume)) + return append(errorList, validation.ValidatePersistentVolumeUpdate(obj.(*api.PersistentVolume), old.(*api.PersistentVolume))...) } type persistentvolumeStatusStrategy struct { diff --git a/pkg/registry/persistentvolumeclaim/rest.go b/pkg/registry/persistentvolumeclaim/rest.go index 2d09aa318d..f0e2934c67 100644 --- a/pkg/registry/persistentvolumeclaim/rest.go +++ b/pkg/registry/persistentvolumeclaim/rest.go @@ -65,7 +65,8 @@ func (persistentvolumeclaimStrategy) PrepareForUpdate(obj, old runtime.Object) { } func (persistentvolumeclaimStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidatePersistentVolumeClaimUpdate(obj.(*api.PersistentVolumeClaim), old.(*api.PersistentVolumeClaim)) + errorList := validation.ValidatePersistentVolumeClaim(obj.(*api.PersistentVolumeClaim)) + return append(errorList, validation.ValidatePersistentVolumeClaimUpdate(obj.(*api.PersistentVolumeClaim), old.(*api.PersistentVolumeClaim))...) } type persistentvolumeclaimStatusStrategy struct { diff --git a/pkg/registry/pod/etcd/etcd_test.go b/pkg/registry/pod/etcd/etcd_test.go index d682ddda0f..cdbac4fd46 100644 --- a/pkg/registry/pod/etcd/etcd_test.go +++ b/pkg/registry/pod/etcd/etcd_test.go @@ -1062,6 +1062,7 @@ func TestEtcdUpdateScheduled(t *testing.T) { Host: "machine", Containers: []api.Container{ { + Name: "foobar", Image: "foo:v1", }, }, @@ -1080,6 +1081,7 @@ func TestEtcdUpdateScheduled(t *testing.T) { Host: "machine", Containers: []api.Container{ { + Name: "foobar", Image: "foo:v2", ImagePullPolicy: api.PullIfNotPresent, TerminationMessagePath: api.TerminationMessagePathDefault, diff --git a/pkg/registry/pod/rest.go b/pkg/registry/pod/rest.go index 04aab00826..4db998ce1a 100644 --- a/pkg/registry/pod/rest.go +++ b/pkg/registry/pod/rest.go @@ -79,7 +79,8 @@ func (podStrategy) AllowCreateOnUpdate() bool { // ValidateUpdate is the default update validation for an end user. func (podStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidatePodUpdate(obj.(*api.Pod), old.(*api.Pod)) + errorList := validation.ValidatePod(obj.(*api.Pod)) + return append(errorList, validation.ValidatePodUpdate(obj.(*api.Pod), old.(*api.Pod))...) } // CheckGracefulDelete allows a pod to be gracefully deleted. diff --git a/pkg/registry/resourcequota/rest.go b/pkg/registry/resourcequota/rest.go index b008adc6dd..892ff23ea0 100644 --- a/pkg/registry/resourcequota/rest.go +++ b/pkg/registry/resourcequota/rest.go @@ -69,7 +69,8 @@ func (resourcequotaStrategy) AllowCreateOnUpdate() bool { // ValidateUpdate is the default update validation for an end user. func (resourcequotaStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidateResourceQuotaUpdate(obj.(*api.ResourceQuota), old.(*api.ResourceQuota)) + errorList := validation.ValidateResourceQuota(obj.(*api.ResourceQuota)) + return append(errorList, validation.ValidateResourceQuotaUpdate(obj.(*api.ResourceQuota), old.(*api.ResourceQuota))...) } type resourcequotaStatusStrategy struct {