mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-23 18:40:53 +00:00
Make order of fun consistent
This commit is contained in:
parent
c095e35f1b
commit
501c2825cf
@ -235,7 +235,7 @@ func ValidatePositiveQuantity(value resource.Quantity, fieldName string) errs.Va
|
|||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateImmutableField(old, new interface{}, fieldName string) errs.ValidationErrorList {
|
func ValidateImmutableField(new, old interface{}, fieldName string) errs.ValidationErrorList {
|
||||||
allErrs := errs.ValidationErrorList{}
|
allErrs := errs.ValidationErrorList{}
|
||||||
if !api.Semantic.DeepEqual(old, new) {
|
if !api.Semantic.DeepEqual(old, new) {
|
||||||
allErrs = append(allErrs, errs.NewFieldInvalid(fieldName, new, fieldImmutableErrorMsg))
|
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, 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(new.Name, old.Name, "name")...)
|
||||||
allErrs = append(allErrs, ValidateImmutableField(old.Namespace, new.Namespace, "namespace")...)
|
allErrs = append(allErrs, ValidateImmutableField(new.Namespace, old.Namespace, "namespace")...)
|
||||||
allErrs = append(allErrs, ValidateImmutableField(old.UID, new.UID, "uid")...)
|
allErrs = append(allErrs, ValidateImmutableField(new.UID, old.UID, "uid")...)
|
||||||
allErrs = append(allErrs, ValidateImmutableField(old.CreationTimestamp, new.CreationTimestamp, "creationTimestamp")...)
|
allErrs = append(allErrs, ValidateImmutableField(new.CreationTimestamp, old.CreationTimestamp, "creationTimestamp")...)
|
||||||
|
|
||||||
allErrs = append(allErrs, ValidateLabels(new.Labels, "labels")...)
|
allErrs = append(allErrs, ValidateLabels(new.Labels, "labels")...)
|
||||||
allErrs = append(allErrs, ValidateAnnotations(new.Annotations, "annotations")...)
|
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
|
// 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 := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, ValidateObjectMetaUpdate(&service.ObjectMeta, &oldService.ObjectMeta).Prefix("metadata")...)
|
allErrs = append(allErrs, ValidateObjectMetaUpdate(&service.ObjectMeta, &oldService.ObjectMeta).Prefix("metadata")...)
|
||||||
|
|
||||||
if api.IsServiceIPSet(oldService) {
|
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)...)
|
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.
|
// 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 := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, ValidateObjectMetaUpdate(&controller.ObjectMeta, &oldController.ObjectMeta).Prefix("metadata")...)
|
allErrs = append(allErrs, ValidateObjectMetaUpdate(&controller.ObjectMeta, &oldController.ObjectMeta).Prefix("metadata")...)
|
||||||
allErrs = append(allErrs, ValidateReplicationControllerSpec(&controller.Spec).Prefix("spec")...)
|
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.
|
// 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 := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, ValidateObjectMetaUpdate(&controller.ObjectMeta, &oldController.ObjectMeta).Prefix("metadata")...)
|
allErrs = append(allErrs, ValidateObjectMetaUpdate(&controller.ObjectMeta, &oldController.ObjectMeta).Prefix("metadata")...)
|
||||||
allErrs = append(allErrs, ValidatePositiveField(int64(controller.Status.Replicas), "status.replicas")...)
|
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.
|
// 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 := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, ValidateObjectMetaUpdate(&node.ObjectMeta, &oldNode.ObjectMeta).Prefix("metadata")...)
|
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.
|
// 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 := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, ValidateObjectMetaUpdate(&newServiceAccount.ObjectMeta, &oldServiceAccount.ObjectMeta).Prefix("metadata")...)
|
allErrs = append(allErrs, ValidateObjectMetaUpdate(&newServiceAccount.ObjectMeta, &oldServiceAccount.ObjectMeta).Prefix("metadata")...)
|
||||||
allErrs = append(allErrs, ValidateServiceAccount(newServiceAccount)...)
|
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.
|
// 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 := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, ValidateObjectMetaUpdate(&newSecret.ObjectMeta, &oldSecret.ObjectMeta).Prefix("metadata")...)
|
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
|
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)...)
|
allErrs = append(allErrs, ValidateSecret(newSecret)...)
|
||||||
return allErrs
|
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.
|
// 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 := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, ValidateObjectMetaUpdate(&newEndpoints.ObjectMeta, &oldEndpoints.ObjectMeta).Prefix("metadata")...)
|
allErrs = append(allErrs, ValidateObjectMetaUpdate(&newEndpoints.ObjectMeta, &oldEndpoints.ObjectMeta).Prefix("metadata")...)
|
||||||
allErrs = append(allErrs, validateEndpointSubsets(newEndpoints.Subsets).Prefix("subsets")...)
|
allErrs = append(allErrs, validateEndpointSubsets(newEndpoints.Subsets).Prefix("subsets")...)
|
||||||
|
@ -2160,7 +2160,7 @@ func TestValidateReplicationControllerStatusUpdate(t *testing.T) {
|
|||||||
for _, successCase := range successCases {
|
for _, successCase := range successCases {
|
||||||
successCase.old.ObjectMeta.ResourceVersion = "1"
|
successCase.old.ObjectMeta.ResourceVersion = "1"
|
||||||
successCase.update.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)
|
t.Errorf("expected success: %v", errs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2190,7 +2190,7 @@ func TestValidateReplicationControllerStatusUpdate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for testName, errorCase := range errorCases {
|
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)
|
t.Errorf("expected failure: %s", testName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2279,7 +2279,7 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
|
|||||||
for _, successCase := range successCases {
|
for _, successCase := range successCases {
|
||||||
successCase.old.ObjectMeta.ResourceVersion = "1"
|
successCase.old.ObjectMeta.ResourceVersion = "1"
|
||||||
successCase.update.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)
|
t.Errorf("expected success: %v", errs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2354,7 +2354,7 @@ func TestValidateReplicationControllerUpdate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for testName, errorCase := range errorCases {
|
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)
|
t.Errorf("expected failure: %s", testName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2864,7 +2864,7 @@ func TestValidateNodeUpdate(t *testing.T) {
|
|||||||
for i, test := range tests {
|
for i, test := range tests {
|
||||||
test.oldNode.ObjectMeta.ResourceVersion = "1"
|
test.oldNode.ObjectMeta.ResourceVersion = "1"
|
||||||
test.node.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 {
|
if test.valid && len(errs) > 0 {
|
||||||
t.Errorf("%d: Unexpected error: %v", i, errs)
|
t.Errorf("%d: Unexpected error: %v", i, errs)
|
||||||
t.Logf("%#v vs %#v", test.oldNode.ObjectMeta, test.node.ObjectMeta)
|
t.Logf("%#v vs %#v", test.oldNode.ObjectMeta, test.node.ObjectMeta)
|
||||||
@ -2973,7 +2973,7 @@ func TestValidateServiceUpdate(t *testing.T) {
|
|||||||
oldSvc := makeValidService()
|
oldSvc := makeValidService()
|
||||||
newSvc := makeValidService()
|
newSvc := makeValidService()
|
||||||
tc.tweakSvc(&oldSvc, &newSvc)
|
tc.tweakSvc(&oldSvc, &newSvc)
|
||||||
errs := ValidateServiceUpdate(&oldSvc, &newSvc)
|
errs := ValidateServiceUpdate(&newSvc, &oldSvc)
|
||||||
if len(errs) != tc.numErrs {
|
if len(errs) != tc.numErrs {
|
||||||
t.Errorf("Unexpected error list for case %q: %v", tc.name, utilerrors.NewAggregate(errs))
|
t.Errorf("Unexpected error list for case %q: %v", tc.name, utilerrors.NewAggregate(errs))
|
||||||
}
|
}
|
||||||
|
@ -109,7 +109,7 @@ func ValidateHorizontalPodAutoscalerStatusUpdate(controller, oldController *exte
|
|||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateThirdPartyResourceUpdate(old, update *extensions.ThirdPartyResource) errs.ValidationErrorList {
|
func ValidateThirdPartyResourceUpdate(update, old *extensions.ThirdPartyResource) errs.ValidationErrorList {
|
||||||
return ValidateThirdPartyResource(update)
|
return ValidateThirdPartyResource(update)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -141,11 +141,11 @@ func ValidateDaemonSet(controller *extensions.DaemonSet) errs.ValidationErrorLis
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ValidateDaemonSetUpdate tests if required fields in the DaemonSet are set.
|
// 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 := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&controller.ObjectMeta, &oldController.ObjectMeta).Prefix("metadata")...)
|
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&controller.ObjectMeta, &oldController.ObjectMeta).Prefix("metadata")...)
|
||||||
allErrs = append(allErrs, ValidateDaemonSetSpec(&controller.Spec).Prefix("spec")...)
|
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
|
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.
|
// 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{}
|
allErrs := errs.ValidationErrorList{}
|
||||||
podSpec := podTemplate.Spec
|
podSpec := podTemplate.Spec
|
||||||
// podTemplate.Spec is not a pointer, so we can modify NodeSelector and NodeName directly.
|
// 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
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateDeploymentUpdate(old, update *extensions.Deployment) errs.ValidationErrorList {
|
func ValidateDeploymentUpdate(update, old *extensions.Deployment) errs.ValidationErrorList {
|
||||||
allErrs := errs.ValidationErrorList{}
|
allErrs := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&update.ObjectMeta, &old.ObjectMeta).Prefix("metadata")...)
|
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&update.ObjectMeta, &old.ObjectMeta).Prefix("metadata")...)
|
||||||
allErrs = append(allErrs, ValidateDeploymentSpec(&update.Spec).Prefix("spec")...)
|
allErrs = append(allErrs, ValidateDeploymentSpec(&update.Spec).Prefix("spec")...)
|
||||||
@ -312,7 +312,7 @@ func ValidateDeployment(obj *extensions.Deployment) errs.ValidationErrorList {
|
|||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateThirdPartyResourceDataUpdate(old, update *extensions.ThirdPartyResourceData) errs.ValidationErrorList {
|
func ValidateThirdPartyResourceDataUpdate(update, old *extensions.ThirdPartyResourceData) errs.ValidationErrorList {
|
||||||
return ValidateThirdPartyResourceData(update)
|
return ValidateThirdPartyResourceData(update)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -371,30 +371,30 @@ func ValidateJobStatus(status *extensions.JobStatus) errs.ValidationErrorList {
|
|||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateJobUpdate(oldJob, job *extensions.Job) errs.ValidationErrorList {
|
func ValidateJobUpdate(job, oldJob *extensions.Job) errs.ValidationErrorList {
|
||||||
allErrs := errs.ValidationErrorList{}
|
allErrs := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&oldJob.ObjectMeta, &job.ObjectMeta).Prefix("metadata")...)
|
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
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateJobUpdateStatus(oldJob, job *extensions.Job) errs.ValidationErrorList {
|
func ValidateJobUpdateStatus(job, oldJob *extensions.Job) errs.ValidationErrorList {
|
||||||
allErrs := errs.ValidationErrorList{}
|
allErrs := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&oldJob.ObjectMeta, &job.ObjectMeta).Prefix("metadata")...)
|
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
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateJobSpecUpdate(oldSpec, spec extensions.JobSpec) errs.ValidationErrorList {
|
func ValidateJobSpecUpdate(spec, oldSpec extensions.JobSpec) errs.ValidationErrorList {
|
||||||
allErrs := errs.ValidationErrorList{}
|
allErrs := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, ValidateJobSpec(&spec)...)
|
allErrs = append(allErrs, ValidateJobSpec(&spec)...)
|
||||||
allErrs = append(allErrs, apivalidation.ValidateImmutableField(oldSpec.Completions, spec.Completions, "completions")...)
|
allErrs = append(allErrs, apivalidation.ValidateImmutableField(spec.Completions, oldSpec.Completions, "completions")...)
|
||||||
allErrs = append(allErrs, apivalidation.ValidateImmutableField(oldSpec.Selector, spec.Selector, "selector")...)
|
allErrs = append(allErrs, apivalidation.ValidateImmutableField(spec.Selector, oldSpec.Selector, "selector")...)
|
||||||
allErrs = append(allErrs, apivalidation.ValidateImmutableField(oldSpec.Template, spec.Template, "template")...)
|
allErrs = append(allErrs, apivalidation.ValidateImmutableField(spec.Template, oldSpec.Template, "template")...)
|
||||||
return allErrs
|
return allErrs
|
||||||
}
|
}
|
||||||
|
|
||||||
func ValidateJobStatusUpdate(oldStatus, status extensions.JobStatus) errs.ValidationErrorList {
|
func ValidateJobStatusUpdate(status, oldStatus extensions.JobStatus) errs.ValidationErrorList {
|
||||||
allErrs := errs.ValidationErrorList{}
|
allErrs := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, ValidateJobStatus(&status)...)
|
allErrs = append(allErrs, ValidateJobStatus(&status)...)
|
||||||
return allErrs
|
return allErrs
|
||||||
@ -429,7 +429,7 @@ func ValidateIngressSpec(spec *extensions.IngressSpec) errs.ValidationErrorList
|
|||||||
}
|
}
|
||||||
|
|
||||||
// ValidateIngressUpdate tests if required fields in the Ingress are set.
|
// 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 := errs.ValidationErrorList{}
|
||||||
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&ingress.ObjectMeta, &oldIngress.ObjectMeta).Prefix("metadata")...)
|
allErrs = append(allErrs, apivalidation.ValidateObjectMetaUpdate(&ingress.ObjectMeta, &oldIngress.ObjectMeta).Prefix("metadata")...)
|
||||||
allErrs = append(allErrs, ValidateIngressSpec(&ingress.Spec).Prefix("spec")...)
|
allErrs = append(allErrs, ValidateIngressSpec(&ingress.Spec).Prefix("spec")...)
|
||||||
|
@ -417,7 +417,7 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
|
|||||||
for _, successCase := range successCases {
|
for _, successCase := range successCases {
|
||||||
successCase.old.ObjectMeta.ResourceVersion = "1"
|
successCase.old.ObjectMeta.ResourceVersion = "1"
|
||||||
successCase.update.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)
|
t.Errorf("expected success: %v", errs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -504,7 +504,7 @@ func TestValidateDaemonSetUpdate(t *testing.T) {
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
for testName, errorCase := range errorCases {
|
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)
|
t.Errorf("expected failure: %s", testName)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -90,7 +90,7 @@ func (rcStrategy) AllowCreateOnUpdate() bool {
|
|||||||
// ValidateUpdate is the default update validation for an end user.
|
// ValidateUpdate is the default update validation for an end user.
|
||||||
func (rcStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
func (rcStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
||||||
validationErrorList := validation.ValidateReplicationController(obj.(*api.ReplicationController))
|
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...)
|
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 {
|
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))
|
||||||
}
|
}
|
||||||
|
@ -91,7 +91,7 @@ func (daemonSetStrategy) AllowCreateOnUpdate() bool {
|
|||||||
// ValidateUpdate is the default update validation for an end user.
|
// ValidateUpdate is the default update validation for an end user.
|
||||||
func (daemonSetStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
func (daemonSetStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
||||||
validationErrorList := validation.ValidateDaemonSet(obj.(*extensions.DaemonSet))
|
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...)
|
return append(validationErrorList, updateErrorList...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ func (deploymentStrategy) PrepareForUpdate(obj, old runtime.Object) {
|
|||||||
|
|
||||||
// ValidateUpdate is the default update validation for an end user.
|
// ValidateUpdate is the default update validation for an end user.
|
||||||
func (deploymentStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) errs.ValidationErrorList {
|
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 {
|
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
|
// ValidateUpdate is the default update validation for an end user updating status
|
||||||
func (deploymentStatusStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) errs.ValidationErrorList {
|
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.
|
// DeploymentToSelectableFields returns a field set that represents the object.
|
||||||
|
@ -70,7 +70,7 @@ func (endpointsStrategy) AllowCreateOnUpdate() bool {
|
|||||||
// ValidateUpdate is the default update validation for an end user.
|
// ValidateUpdate is the default update validation for an end user.
|
||||||
func (endpointsStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
func (endpointsStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
||||||
errorList := validation.ValidateEndpoints(obj.(*api.Endpoints))
|
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 {
|
func (endpointsStrategy) AllowUnconditionalUpdate() bool {
|
||||||
|
@ -84,7 +84,7 @@ func (ingressStrategy) AllowCreateOnUpdate() bool {
|
|||||||
// ValidateUpdate is the default update validation for an end user.
|
// ValidateUpdate is the default update validation for an end user.
|
||||||
func (ingressStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
func (ingressStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
||||||
validationErrorList := validation.ValidateIngress(obj.(*extensions.Ingress))
|
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...)
|
return append(validationErrorList, updateErrorList...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,7 +75,7 @@ func (jobStrategy) AllowCreateOnUpdate() bool {
|
|||||||
// ValidateUpdate is the default update validation for an end user.
|
// ValidateUpdate is the default update validation for an end user.
|
||||||
func (jobStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
func (jobStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
||||||
validationErrorList := validation.ValidateJob(obj.(*extensions.Job))
|
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...)
|
return append(validationErrorList, updateErrorList...)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.
|
// ValidateUpdate is the default update validation for an end user.
|
||||||
func (nodeStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
func (nodeStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
||||||
errorList := validation.ValidateNode(obj.(*api.Node))
|
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 {
|
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 {
|
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.
|
// ResourceGetter is an interface for retrieving resources by ResourceLocation.
|
||||||
|
@ -62,7 +62,7 @@ func (strategy) PrepareForUpdate(obj, old runtime.Object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (strategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
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 {
|
func (strategy) AllowUnconditionalUpdate() bool {
|
||||||
|
@ -202,7 +202,7 @@ func (rs *REST) Update(ctx api.Context, obj runtime.Object) (runtime.Object, boo
|
|||||||
|
|
||||||
// Copy over non-user fields
|
// Copy over non-user fields
|
||||||
// TODO: make this a merge function
|
// 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)
|
return nil, false, errors.NewInvalid("service", service.Name, errs)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,7 +68,7 @@ func (svcStrategy) AllowCreateOnUpdate() bool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (svcStrategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
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 {
|
func (svcStrategy) AllowUnconditionalUpdate() bool {
|
||||||
|
@ -65,7 +65,7 @@ func cleanSecretReferences(serviceAccount *api.ServiceAccount) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (strategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
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 {
|
func (strategy) AllowUnconditionalUpdate() bool {
|
||||||
|
@ -63,7 +63,7 @@ func (strategy) PrepareForUpdate(obj, old runtime.Object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (strategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
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 {
|
func (strategy) AllowUnconditionalUpdate() bool {
|
||||||
|
@ -63,7 +63,7 @@ func (strategy) PrepareForUpdate(obj, old runtime.Object) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (strategy) ValidateUpdate(ctx api.Context, obj, old runtime.Object) fielderrors.ValidationErrorList {
|
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 {
|
func (strategy) AllowUnconditionalUpdate() bool {
|
||||||
|
Loading…
Reference in New Issue
Block a user