From 501c2825cfc4ebdb7eecf954487cfe3515700327 Mon Sep 17 00:00:00 2001 From: eulerzgy Date: Wed, 4 Nov 2015 15:47:11 +0800 Subject: [PATCH] Make order of fun consistent --- pkg/api/validation/validation.go | 28 ++++++++-------- pkg/api/validation/validation_test.go | 12 +++---- pkg/apis/extensions/validation/validation.go | 32 +++++++++---------- .../extensions/validation/validation_test.go | 4 +-- pkg/registry/controller/strategy.go | 4 +-- pkg/registry/daemonset/strategy.go | 2 +- pkg/registry/deployment/strategy.go | 4 +-- pkg/registry/endpoint/strategy.go | 2 +- pkg/registry/ingress/strategy.go | 2 +- pkg/registry/job/strategy.go | 2 +- pkg/registry/node/strategy.go | 4 +-- pkg/registry/secret/strategy.go | 2 +- pkg/registry/service/rest.go | 2 +- pkg/registry/service/strategy.go | 2 +- pkg/registry/serviceaccount/strategy.go | 2 +- pkg/registry/thirdpartyresource/strategy.go | 2 +- .../thirdpartyresourcedata/strategy.go | 2 +- 17 files changed, 54 insertions(+), 54 deletions(-) diff --git a/pkg/api/validation/validation.go b/pkg/api/validation/validation.go index 0d37921f643..34591dafb92 100644 --- a/pkg/api/validation/validation.go +++ b/pkg/api/validation/validation.go @@ -235,7 +235,7 @@ func ValidatePositiveQuantity(value resource.Quantity, fieldName string) errs.Va return allErrs } -func ValidateImmutableField(old, new interface{}, fieldName string) errs.ValidationErrorList { +func ValidateImmutableField(new, old interface{}, fieldName string) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} if !api.Semantic.DeepEqual(old, new) { allErrs = append(allErrs, errs.NewFieldInvalid(fieldName, new, fieldImmutableErrorMsg)) @@ -324,10 +324,10 @@ func ValidateObjectMetaUpdate(new, old *api.ObjectMeta) errs.ValidationErrorList allErrs = append(allErrs, errs.NewFieldInvalid("resourceVersion", new.ResourceVersion, "resourceVersion must be specified for an update")) } - allErrs = append(allErrs, ValidateImmutableField(old.Name, new.Name, "name")...) - allErrs = append(allErrs, ValidateImmutableField(old.Namespace, new.Namespace, "namespace")...) - allErrs = append(allErrs, ValidateImmutableField(old.UID, new.UID, "uid")...) - allErrs = append(allErrs, ValidateImmutableField(old.CreationTimestamp, new.CreationTimestamp, "creationTimestamp")...) + allErrs = append(allErrs, ValidateImmutableField(new.Name, old.Name, "name")...) + allErrs = append(allErrs, ValidateImmutableField(new.Namespace, old.Namespace, "namespace")...) + allErrs = append(allErrs, ValidateImmutableField(new.UID, old.UID, "uid")...) + allErrs = append(allErrs, ValidateImmutableField(new.CreationTimestamp, old.CreationTimestamp, "creationTimestamp")...) allErrs = append(allErrs, ValidateLabels(new.Labels, "labels")...) allErrs = append(allErrs, ValidateAnnotations(new.Annotations, "annotations")...) @@ -1345,12 +1345,12 @@ func validateServicePort(sp *api.ServicePort, requireName bool, allNames *sets.S } // ValidateServiceUpdate tests if required fields in the service are set during an update -func ValidateServiceUpdate(oldService, service *api.Service) errs.ValidationErrorList { +func ValidateServiceUpdate(service, oldService *api.Service) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, ValidateObjectMetaUpdate(&service.ObjectMeta, &oldService.ObjectMeta).Prefix("metadata")...) if api.IsServiceIPSet(oldService) { - allErrs = append(allErrs, ValidateImmutableField(oldService.Spec.ClusterIP, service.Spec.ClusterIP, "spec.clusterIP")...) + allErrs = append(allErrs, ValidateImmutableField(service.Spec.ClusterIP, oldService.Spec.ClusterIP, "spec.clusterIP")...) } allErrs = append(allErrs, ValidateService(service)...) @@ -1366,7 +1366,7 @@ func ValidateReplicationController(controller *api.ReplicationController) errs.V } // ValidateReplicationControllerUpdate tests if required fields in the replication controller are set. -func ValidateReplicationControllerUpdate(oldController, controller *api.ReplicationController) errs.ValidationErrorList { +func ValidateReplicationControllerUpdate(controller, oldController *api.ReplicationController) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, ValidateObjectMetaUpdate(&controller.ObjectMeta, &oldController.ObjectMeta).Prefix("metadata")...) allErrs = append(allErrs, ValidateReplicationControllerSpec(&controller.Spec).Prefix("spec")...) @@ -1374,7 +1374,7 @@ func ValidateReplicationControllerUpdate(oldController, controller *api.Replicat } // ValidateReplicationControllerStatusUpdate tests if required fields in the replication controller are set. -func ValidateReplicationControllerStatusUpdate(oldController, controller *api.ReplicationController) errs.ValidationErrorList { +func ValidateReplicationControllerStatusUpdate(controller, oldController *api.ReplicationController) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, ValidateObjectMetaUpdate(&controller.ObjectMeta, &oldController.ObjectMeta).Prefix("metadata")...) allErrs = append(allErrs, ValidatePositiveField(int64(controller.Status.Replicas), "status.replicas")...) @@ -1467,7 +1467,7 @@ func ValidateNode(node *api.Node) errs.ValidationErrorList { } // ValidateNodeUpdate tests to make sure a node update can be applied. Modifies oldNode. -func ValidateNodeUpdate(oldNode *api.Node, node *api.Node) errs.ValidationErrorList { +func ValidateNodeUpdate(node *api.Node, oldNode *api.Node) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, ValidateObjectMetaUpdate(&node.ObjectMeta, &oldNode.ObjectMeta).Prefix("metadata")...) @@ -1644,7 +1644,7 @@ func ValidateServiceAccount(serviceAccount *api.ServiceAccount) errs.ValidationE } // ValidateServiceAccountUpdate tests if required fields in the ServiceAccount are set. -func ValidateServiceAccountUpdate(oldServiceAccount, newServiceAccount *api.ServiceAccount) errs.ValidationErrorList { +func ValidateServiceAccountUpdate(newServiceAccount, oldServiceAccount *api.ServiceAccount) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, ValidateObjectMetaUpdate(&newServiceAccount.ObjectMeta, &oldServiceAccount.ObjectMeta).Prefix("metadata")...) allErrs = append(allErrs, ValidateServiceAccount(newServiceAccount)...) @@ -1708,7 +1708,7 @@ func ValidateSecret(secret *api.Secret) errs.ValidationErrorList { } // ValidateSecretUpdate tests if required fields in the Secret are set. -func ValidateSecretUpdate(oldSecret, newSecret *api.Secret) errs.ValidationErrorList { +func ValidateSecretUpdate(newSecret, oldSecret *api.Secret) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, ValidateObjectMetaUpdate(&newSecret.ObjectMeta, &oldSecret.ObjectMeta).Prefix("metadata")...) @@ -1716,7 +1716,7 @@ func ValidateSecretUpdate(oldSecret, newSecret *api.Secret) errs.ValidationError newSecret.Type = oldSecret.Type } - allErrs = append(allErrs, ValidateImmutableField(oldSecret.Type, newSecret.Type, "type")...) + allErrs = append(allErrs, ValidateImmutableField(newSecret.Type, oldSecret.Type, "type")...) allErrs = append(allErrs, ValidateSecret(newSecret)...) return allErrs @@ -1981,7 +1981,7 @@ func validateEndpointPort(port *api.EndpointPort, requireName bool) errs.Validat } // ValidateEndpointsUpdate tests to make sure an endpoints update can be applied. -func ValidateEndpointsUpdate(oldEndpoints, newEndpoints *api.Endpoints) errs.ValidationErrorList { +func ValidateEndpointsUpdate(newEndpoints, oldEndpoints *api.Endpoints) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, ValidateObjectMetaUpdate(&newEndpoints.ObjectMeta, &oldEndpoints.ObjectMeta).Prefix("metadata")...) allErrs = append(allErrs, validateEndpointSubsets(newEndpoints.Subsets).Prefix("subsets")...) diff --git a/pkg/api/validation/validation_test.go b/pkg/api/validation/validation_test.go index 2b2a4ed7193..fb67dc21f57 100644 --- a/pkg/api/validation/validation_test.go +++ b/pkg/api/validation/validation_test.go @@ -2160,7 +2160,7 @@ func TestValidateReplicationControllerStatusUpdate(t *testing.T) { for _, successCase := range successCases { successCase.old.ObjectMeta.ResourceVersion = "1" successCase.update.ObjectMeta.ResourceVersion = "1" - if errs := ValidateReplicationControllerStatusUpdate(&successCase.old, &successCase.update); len(errs) != 0 { + if errs := ValidateReplicationControllerStatusUpdate(&successCase.update, &successCase.old); len(errs) != 0 { t.Errorf("expected success: %v", errs) } } @@ -2190,7 +2190,7 @@ func TestValidateReplicationControllerStatusUpdate(t *testing.T) { }, } for testName, errorCase := range errorCases { - if errs := ValidateReplicationControllerStatusUpdate(&errorCase.old, &errorCase.update); len(errs) == 0 { + if errs := ValidateReplicationControllerStatusUpdate(&errorCase.update, &errorCase.old); len(errs) == 0 { t.Errorf("expected failure: %s", testName) } } @@ -2279,7 +2279,7 @@ func TestValidateReplicationControllerUpdate(t *testing.T) { for _, successCase := range successCases { successCase.old.ObjectMeta.ResourceVersion = "1" successCase.update.ObjectMeta.ResourceVersion = "1" - if errs := ValidateReplicationControllerUpdate(&successCase.old, &successCase.update); len(errs) != 0 { + if errs := ValidateReplicationControllerUpdate(&successCase.update, &successCase.old); len(errs) != 0 { t.Errorf("expected success: %v", errs) } } @@ -2354,7 +2354,7 @@ func TestValidateReplicationControllerUpdate(t *testing.T) { }, } for testName, errorCase := range errorCases { - if errs := ValidateReplicationControllerUpdate(&errorCase.old, &errorCase.update); len(errs) == 0 { + if errs := ValidateReplicationControllerUpdate(&errorCase.update, &errorCase.old); len(errs) == 0 { t.Errorf("expected failure: %s", testName) } } @@ -2864,7 +2864,7 @@ func TestValidateNodeUpdate(t *testing.T) { for i, test := range tests { test.oldNode.ObjectMeta.ResourceVersion = "1" test.node.ObjectMeta.ResourceVersion = "1" - errs := ValidateNodeUpdate(&test.oldNode, &test.node) + errs := ValidateNodeUpdate(&test.node, &test.oldNode) if test.valid && len(errs) > 0 { t.Errorf("%d: Unexpected error: %v", i, errs) t.Logf("%#v vs %#v", test.oldNode.ObjectMeta, test.node.ObjectMeta) @@ -2973,7 +2973,7 @@ func TestValidateServiceUpdate(t *testing.T) { oldSvc := makeValidService() newSvc := makeValidService() tc.tweakSvc(&oldSvc, &newSvc) - errs := ValidateServiceUpdate(&oldSvc, &newSvc) + errs := ValidateServiceUpdate(&newSvc, &oldSvc) if len(errs) != tc.numErrs { t.Errorf("Unexpected error list for case %q: %v", tc.name, utilerrors.NewAggregate(errs)) } diff --git a/pkg/apis/extensions/validation/validation.go b/pkg/apis/extensions/validation/validation.go index c687b23db6d..5a256398e1c 100644 --- a/pkg/apis/extensions/validation/validation.go +++ b/pkg/apis/extensions/validation/validation.go @@ -109,7 +109,7 @@ func ValidateHorizontalPodAutoscalerStatusUpdate(controller, oldController *exte return allErrs } -func ValidateThirdPartyResourceUpdate(old, update *extensions.ThirdPartyResource) errs.ValidationErrorList { +func ValidateThirdPartyResourceUpdate(update, old *extensions.ThirdPartyResource) errs.ValidationErrorList { return ValidateThirdPartyResource(update) } @@ -141,11 +141,11 @@ func ValidateDaemonSet(controller *extensions.DaemonSet) errs.ValidationErrorLis } // ValidateDaemonSetUpdate tests if required fields in the DaemonSet are set. -func ValidateDaemonSetUpdate(oldController, controller *extensions.DaemonSet) errs.ValidationErrorList { +func ValidateDaemonSetUpdate(controller, oldController *extensions.DaemonSet) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&controller.ObjectMeta, &oldController.ObjectMeta).Prefix("metadata")...) allErrs = append(allErrs, ValidateDaemonSetSpec(&controller.Spec).Prefix("spec")...) - allErrs = append(allErrs, ValidateDaemonSetTemplateUpdate(oldController.Spec.Template, controller.Spec.Template).Prefix("spec.template")...) + allErrs = append(allErrs, ValidateDaemonSetTemplateUpdate(controller.Spec.Template, oldController.Spec.Template).Prefix("spec.template")...) return allErrs } @@ -167,7 +167,7 @@ func ValidateDaemonSetStatusUpdate(controller, oldController *extensions.DaemonS } // ValidateDaemonSetTemplateUpdate tests that certain fields in the daemon set's pod template are not updated. -func ValidateDaemonSetTemplateUpdate(oldPodTemplate, podTemplate *api.PodTemplateSpec) errs.ValidationErrorList { +func ValidateDaemonSetTemplateUpdate(podTemplate, oldPodTemplate *api.PodTemplateSpec) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} podSpec := podTemplate.Spec // podTemplate.Spec is not a pointer, so we can modify NodeSelector and NodeName directly. @@ -298,7 +298,7 @@ func ValidateDeploymentSpec(spec *extensions.DeploymentSpec) errs.ValidationErro return allErrs } -func ValidateDeploymentUpdate(old, update *extensions.Deployment) errs.ValidationErrorList { +func ValidateDeploymentUpdate(update, old *extensions.Deployment) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&update.ObjectMeta, &old.ObjectMeta).Prefix("metadata")...) allErrs = append(allErrs, ValidateDeploymentSpec(&update.Spec).Prefix("spec")...) @@ -312,7 +312,7 @@ func ValidateDeployment(obj *extensions.Deployment) errs.ValidationErrorList { return allErrs } -func ValidateThirdPartyResourceDataUpdate(old, update *extensions.ThirdPartyResourceData) errs.ValidationErrorList { +func ValidateThirdPartyResourceDataUpdate(update, old *extensions.ThirdPartyResourceData) errs.ValidationErrorList { return ValidateThirdPartyResourceData(update) } @@ -371,30 +371,30 @@ func ValidateJobStatus(status *extensions.JobStatus) errs.ValidationErrorList { return allErrs } -func ValidateJobUpdate(oldJob, job *extensions.Job) errs.ValidationErrorList { +func ValidateJobUpdate(job, oldJob *extensions.Job) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&oldJob.ObjectMeta, &job.ObjectMeta).Prefix("metadata")...) - allErrs = append(allErrs, ValidateJobSpecUpdate(oldJob.Spec, job.Spec).Prefix("spec")...) + allErrs = append(allErrs, ValidateJobSpecUpdate(job.Spec, oldJob.Spec).Prefix("spec")...) return allErrs } -func ValidateJobUpdateStatus(oldJob, job *extensions.Job) errs.ValidationErrorList { +func ValidateJobUpdateStatus(job, oldJob *extensions.Job) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&oldJob.ObjectMeta, &job.ObjectMeta).Prefix("metadata")...) - allErrs = append(allErrs, ValidateJobStatusUpdate(oldJob.Status, job.Status).Prefix("status")...) + allErrs = append(allErrs, ValidateJobStatusUpdate(job.Status, oldJob.Status).Prefix("status")...) return allErrs } -func ValidateJobSpecUpdate(oldSpec, spec extensions.JobSpec) errs.ValidationErrorList { +func ValidateJobSpecUpdate(spec, oldSpec extensions.JobSpec) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, ValidateJobSpec(&spec)...) - allErrs = append(allErrs, apivalidation.ValidateImmutableField(oldSpec.Completions, spec.Completions, "completions")...) - allErrs = append(allErrs, apivalidation.ValidateImmutableField(oldSpec.Selector, spec.Selector, "selector")...) - allErrs = append(allErrs, apivalidation.ValidateImmutableField(oldSpec.Template, spec.Template, "template")...) + allErrs = append(allErrs, apivalidation.ValidateImmutableField(spec.Completions, oldSpec.Completions, "completions")...) + allErrs = append(allErrs, apivalidation.ValidateImmutableField(spec.Selector, oldSpec.Selector, "selector")...) + allErrs = append(allErrs, apivalidation.ValidateImmutableField(spec.Template, oldSpec.Template, "template")...) return allErrs } -func ValidateJobStatusUpdate(oldStatus, status extensions.JobStatus) errs.ValidationErrorList { +func ValidateJobStatusUpdate(status, oldStatus extensions.JobStatus) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, ValidateJobStatus(&status)...) return allErrs @@ -429,7 +429,7 @@ func ValidateIngressSpec(spec *extensions.IngressSpec) errs.ValidationErrorList } // ValidateIngressUpdate tests if required fields in the Ingress are set. -func ValidateIngressUpdate(oldIngress, ingress *extensions.Ingress) errs.ValidationErrorList { +func ValidateIngressUpdate(ingress, oldIngress *extensions.Ingress) errs.ValidationErrorList { allErrs := errs.ValidationErrorList{} allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&ingress.ObjectMeta, &oldIngress.ObjectMeta).Prefix("metadata")...) allErrs = append(allErrs, ValidateIngressSpec(&ingress.Spec).Prefix("spec")...) diff --git a/pkg/apis/extensions/validation/validation_test.go b/pkg/apis/extensions/validation/validation_test.go index 246e24d29eb..117bd900f75 100644 --- a/pkg/apis/extensions/validation/validation_test.go +++ b/pkg/apis/extensions/validation/validation_test.go @@ -417,7 +417,7 @@ func TestValidateDaemonSetUpdate(t *testing.T) { for _, successCase := range successCases { successCase.old.ObjectMeta.ResourceVersion = "1" successCase.update.ObjectMeta.ResourceVersion = "1" - if errs := ValidateDaemonSetUpdate(&successCase.old, &successCase.update); len(errs) != 0 { + if errs := ValidateDaemonSetUpdate(&successCase.update, &successCase.old); len(errs) != 0 { t.Errorf("expected success: %v", errs) } } @@ -504,7 +504,7 @@ func TestValidateDaemonSetUpdate(t *testing.T) { }, } for testName, errorCase := range errorCases { - if errs := ValidateDaemonSetUpdate(&errorCase.old, &errorCase.update); len(errs) == 0 { + if errs := ValidateDaemonSetUpdate(&errorCase.update, &errorCase.old); len(errs) == 0 { t.Errorf("expected failure: %s", testName) } } diff --git a/pkg/registry/controller/strategy.go b/pkg/registry/controller/strategy.go index 9abb6ec5822..59dbb5db5c5 100644 --- a/pkg/registry/controller/strategy.go +++ b/pkg/registry/controller/strategy.go @@ -90,7 +90,7 @@ 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 { validationErrorList := validation.ValidateReplicationController(obj.(*api.ReplicationController)) - updateErrorList := validation.ValidateReplicationControllerUpdate(old.(*api.ReplicationController), obj.(*api.ReplicationController)) + updateErrorList := validation.ValidateReplicationControllerUpdate(obj.(*api.ReplicationController), old.(*api.ReplicationController)) return append(validationErrorList, updateErrorList...) } @@ -138,5 +138,5 @@ func (rcStatusStrategy) PrepareForUpdate(obj, old runtime.Object) { } func (rcStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidateReplicationControllerStatusUpdate(old.(*api.ReplicationController), obj.(*api.ReplicationController)) + return validation.ValidateReplicationControllerStatusUpdate(obj.(*api.ReplicationController), old.(*api.ReplicationController)) } diff --git a/pkg/registry/daemonset/strategy.go b/pkg/registry/daemonset/strategy.go index 53a3eda0749..b2a9b14c796 100644 --- a/pkg/registry/daemonset/strategy.go +++ b/pkg/registry/daemonset/strategy.go @@ -91,7 +91,7 @@ func (daemonSetStrategy) AllowCreateOnUpdate() bool { // ValidateUpdate is the default update validation for an end user. func (daemonSetStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { validationErrorList := validation.ValidateDaemonSet(obj.(*extensions.DaemonSet)) - updateErrorList := validation.ValidateDaemonSetUpdate(old.(*extensions.DaemonSet), obj.(*extensions.DaemonSet)) + updateErrorList := validation.ValidateDaemonSetUpdate(obj.(*extensions.DaemonSet), old.(*extensions.DaemonSet)) return append(validationErrorList, updateErrorList...) } diff --git a/pkg/registry/deployment/strategy.go b/pkg/registry/deployment/strategy.go index 4d50d47dc07..dd08aee3d3c 100644 --- a/pkg/registry/deployment/strategy.go +++ b/pkg/registry/deployment/strategy.go @@ -70,7 +70,7 @@ func (deploymentStrategy) PrepareForUpdate(obj, old runtime.Object) { // ValidateUpdate is the default update validation for an end user. func (deploymentStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) errs.ValidationErrorList { - return validation.ValidateDeploymentUpdate(old.(*extensions.Deployment), obj.(*extensions.Deployment)) + return validation.ValidateDeploymentUpdate(obj.(*extensions.Deployment), old.(*extensions.Deployment)) } func (deploymentStrategy) AllowUnconditionalUpdate() bool { @@ -92,7 +92,7 @@ func (deploymentStatusStrategy) PrepareForUpdate(obj, old runtime.Object) { // ValidateUpdate is the default update validation for an end user updating status func (deploymentStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) errs.ValidationErrorList { - return validation.ValidateDeploymentUpdate(old.(*extensions.Deployment), obj.(*extensions.Deployment)) + return validation.ValidateDeploymentUpdate(obj.(*extensions.Deployment), old.(*extensions.Deployment)) } // DeploymentToSelectableFields returns a field set that represents the object. diff --git a/pkg/registry/endpoint/strategy.go b/pkg/registry/endpoint/strategy.go index 67eab3b4155..a67f5e624b8 100644 --- a/pkg/registry/endpoint/strategy.go +++ b/pkg/registry/endpoint/strategy.go @@ -70,7 +70,7 @@ 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 { errorList := validation.ValidateEndpoints(obj.(*api.Endpoints)) - return append(errorList, validation.ValidateEndpointsUpdate(old.(*api.Endpoints), obj.(*api.Endpoints))...) + return append(errorList, validation.ValidateEndpointsUpdate(obj.(*api.Endpoints), old.(*api.Endpoints))...) } func (endpointsStrategy) AllowUnconditionalUpdate() bool { diff --git a/pkg/registry/ingress/strategy.go b/pkg/registry/ingress/strategy.go index 05b4f0fef9f..f53931116c4 100644 --- a/pkg/registry/ingress/strategy.go +++ b/pkg/registry/ingress/strategy.go @@ -84,7 +84,7 @@ func (ingressStrategy) AllowCreateOnUpdate() bool { // ValidateUpdate is the default update validation for an end user. func (ingressStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { validationErrorList := validation.ValidateIngress(obj.(*extensions.Ingress)) - updateErrorList := validation.ValidateIngressUpdate(old.(*extensions.Ingress), obj.(*extensions.Ingress)) + updateErrorList := validation.ValidateIngressUpdate(obj.(*extensions.Ingress), old.(*extensions.Ingress)) return append(validationErrorList, updateErrorList...) } diff --git a/pkg/registry/job/strategy.go b/pkg/registry/job/strategy.go index 66aece643c5..7ce425f09c1 100644 --- a/pkg/registry/job/strategy.go +++ b/pkg/registry/job/strategy.go @@ -75,7 +75,7 @@ func (jobStrategy) AllowCreateOnUpdate() bool { // ValidateUpdate is the default update validation for an end user. func (jobStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { validationErrorList := validation.ValidateJob(obj.(*extensions.Job)) - updateErrorList := validation.ValidateJobUpdate(old.(*extensions.Job), obj.(*extensions.Job)) + updateErrorList := validation.ValidateJobUpdate(obj.(*extensions.Job), old.(*extensions.Job)) return append(validationErrorList, updateErrorList...) } diff --git a/pkg/registry/node/strategy.go b/pkg/registry/node/strategy.go index c8167812991..a3a5b9a75c4 100644 --- a/pkg/registry/node/strategy.go +++ b/pkg/registry/node/strategy.go @@ -79,7 +79,7 @@ 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 { errorList := validation.ValidateNode(obj.(*api.Node)) - return append(errorList, validation.ValidateNodeUpdate(old.(*api.Node), obj.(*api.Node))...) + return append(errorList, validation.ValidateNodeUpdate(obj.(*api.Node), old.(*api.Node))...) } func (nodeStrategy) AllowUnconditionalUpdate() bool { @@ -104,7 +104,7 @@ func (nodeStatusStrategy) PrepareForUpdate(obj, old runtime.Object) { } func (nodeStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidateNodeUpdate(old.(*api.Node), obj.(*api.Node)) + return validation.ValidateNodeUpdate(obj.(*api.Node), old.(*api.Node)) } // ResourceGetter is an interface for retrieving resources by ResourceLocation. diff --git a/pkg/registry/secret/strategy.go b/pkg/registry/secret/strategy.go index c4921808ebf..6f1ff04b4c4 100644 --- a/pkg/registry/secret/strategy.go +++ b/pkg/registry/secret/strategy.go @@ -62,7 +62,7 @@ func (strategy) PrepareForUpdate(obj, old runtime.Object) { } func (strategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidateSecretUpdate(old.(*api.Secret), obj.(*api.Secret)) + return validation.ValidateSecretUpdate(obj.(*api.Secret), old.(*api.Secret)) } func (strategy) AllowUnconditionalUpdate() bool { diff --git a/pkg/registry/service/rest.go b/pkg/registry/service/rest.go index 2ae91c3a3d2..b7ceb7a56d1 100644 --- a/pkg/registry/service/rest.go +++ b/pkg/registry/service/rest.go @@ -202,7 +202,7 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (runtime.Object, boo // Copy over non-user fields // TODO: make this a merge function - if errs := validation.ValidateServiceUpdate(oldService, service); len(errs) > 0 { + if errs := validation.ValidateServiceUpdate(service, oldService); len(errs) > 0 { return nil, false, errors.NewInvalid("service", service.Name, errs) } diff --git a/pkg/registry/service/strategy.go b/pkg/registry/service/strategy.go index 80b6ca302c5..c43f3dba897 100644 --- a/pkg/registry/service/strategy.go +++ b/pkg/registry/service/strategy.go @@ -68,7 +68,7 @@ func (svcStrategy) AllowCreateOnUpdate() bool { } func (svcStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidateServiceUpdate(old.(*api.Service), obj.(*api.Service)) + return validation.ValidateServiceUpdate(obj.(*api.Service), old.(*api.Service)) } func (svcStrategy) AllowUnconditionalUpdate() bool { diff --git a/pkg/registry/serviceaccount/strategy.go b/pkg/registry/serviceaccount/strategy.go index d4b97a2b752..915c8b7ca7b 100644 --- a/pkg/registry/serviceaccount/strategy.go +++ b/pkg/registry/serviceaccount/strategy.go @@ -65,7 +65,7 @@ func cleanSecretReferences(serviceAccount *api.ServiceAccount) { } func (strategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidateServiceAccountUpdate(old.(*api.ServiceAccount), obj.(*api.ServiceAccount)) + return validation.ValidateServiceAccountUpdate(obj.(*api.ServiceAccount), old.(*api.ServiceAccount)) } func (strategy) AllowUnconditionalUpdate() bool { diff --git a/pkg/registry/thirdpartyresource/strategy.go b/pkg/registry/thirdpartyresource/strategy.go index fff669ea21e..9ee5081e4e9 100644 --- a/pkg/registry/thirdpartyresource/strategy.go +++ b/pkg/registry/thirdpartyresource/strategy.go @@ -63,7 +63,7 @@ func (strategy) PrepareForUpdate(obj, old runtime.Object) { } func (strategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidateThirdPartyResourceUpdate(old.(*extensions.ThirdPartyResource), obj.(*extensions.ThirdPartyResource)) + return validation.ValidateThirdPartyResourceUpdate(obj.(*extensions.ThirdPartyResource), old.(*extensions.ThirdPartyResource)) } func (strategy) AllowUnconditionalUpdate() bool { diff --git a/pkg/registry/thirdpartyresourcedata/strategy.go b/pkg/registry/thirdpartyresourcedata/strategy.go index 05932374c66..8bf22044ee4 100644 --- a/pkg/registry/thirdpartyresourcedata/strategy.go +++ b/pkg/registry/thirdpartyresourcedata/strategy.go @@ -63,7 +63,7 @@ func (strategy) PrepareForUpdate(obj, old runtime.Object) { } func (strategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList { - return validation.ValidateThirdPartyResourceDataUpdate(old.(*extensions.ThirdPartyResourceData), obj.(*extensions.ThirdPartyResourceData)) + return validation.ValidateThirdPartyResourceDataUpdate(obj.(*extensions.ThirdPartyResourceData), old.(*extensions.ThirdPartyResourceData)) } func (strategy) AllowUnconditionalUpdate() bool {