Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
447fe209
Commit
447fe209
authored
Nov 10, 2015
by
k8s-merge-robot
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #17007 from zhengguoyong/fun_order_consistent
Auto commit by PR queue bot
parents
69427c0a
501c2825
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
54 additions
and
54 deletions
+54
-54
validation.go
pkg/api/validation/validation.go
+14
-14
validation_test.go
pkg/api/validation/validation_test.go
+6
-6
validation.go
pkg/apis/extensions/validation/validation.go
+16
-16
validation_test.go
pkg/apis/extensions/validation/validation_test.go
+2
-2
strategy.go
pkg/registry/controller/strategy.go
+2
-2
strategy.go
pkg/registry/daemonset/strategy.go
+1
-1
strategy.go
pkg/registry/deployment/strategy.go
+2
-2
strategy.go
pkg/registry/endpoint/strategy.go
+1
-1
strategy.go
pkg/registry/ingress/strategy.go
+1
-1
strategy.go
pkg/registry/job/strategy.go
+1
-1
strategy.go
pkg/registry/node/strategy.go
+2
-2
strategy.go
pkg/registry/secret/strategy.go
+1
-1
rest.go
pkg/registry/service/rest.go
+1
-1
strategy.go
pkg/registry/service/strategy.go
+1
-1
strategy.go
pkg/registry/serviceaccount/strategy.go
+1
-1
strategy.go
pkg/registry/thirdpartyresource/strategy.go
+1
-1
strategy.go
pkg/registry/thirdpartyresourcedata/strategy.go
+1
-1
No files found.
pkg/api/validation/validation.go
View file @
447fe209
...
...
@@ -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
,
s
ervice
*
api
.
Service
)
errs
.
ValidationErrorList
{
func
ValidateServiceUpdate
(
service
,
oldS
ervice
*
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
,
s
ervice
.
Spec
.
ClusterIP
,
"spec.clusterIP"
)
...
)
allErrs
=
append
(
allErrs
,
ValidateImmutableField
(
service
.
Spec
.
ClusterIP
,
oldS
ervice
.
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
,
c
ontroller
*
api
.
ReplicationController
)
errs
.
ValidationErrorList
{
func
ValidateReplicationControllerUpdate
(
controller
,
oldC
ontroller
*
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
,
c
ontroller
*
api
.
ReplicationController
)
errs
.
ValidationErrorList
{
func
ValidateReplicationControllerStatusUpdate
(
controller
,
oldC
ontroller
*
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
,
n
ode
*
api
.
Node
)
errs
.
ValidationErrorList
{
func
ValidateNodeUpdate
(
node
*
api
.
Node
,
oldN
ode
*
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
,
new
ServiceAccount
*
api
.
ServiceAccount
)
errs
.
ValidationErrorList
{
func
ValidateServiceAccountUpdate
(
newServiceAccount
,
old
ServiceAccount
*
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
,
new
Secret
*
api
.
Secret
)
errs
.
ValidationErrorList
{
func
ValidateSecretUpdate
(
newSecret
,
old
Secret
*
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
,
new
Secret
.
Type
,
"type"
)
...
)
allErrs
=
append
(
allErrs
,
ValidateImmutableField
(
newSecret
.
Type
,
old
Secret
.
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
,
new
Endpoints
*
api
.
Endpoints
)
errs
.
ValidationErrorList
{
func
ValidateEndpointsUpdate
(
newEndpoints
,
old
Endpoints
*
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"
)
...
)
...
...
pkg/api/validation/validation_test.go
View file @
447fe209
...
...
@@ -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
.
n
ode
)
errs
:=
ValidateNodeUpdate
(
&
test
.
node
,
&
test
.
oldN
ode
)
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
,
&
new
Svc
)
errs
:=
ValidateServiceUpdate
(
&
newSvc
,
&
old
Svc
)
if
len
(
errs
)
!=
tc
.
numErrs
{
t
.
Errorf
(
"Unexpected error list for case %q: %v"
,
tc
.
name
,
utilerrors
.
NewAggregate
(
errs
))
}
...
...
pkg/apis/extensions/validation/validation.go
View file @
447fe209
...
...
@@ -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
,
c
ontroller
*
extensions
.
DaemonSet
)
errs
.
ValidationErrorList
{
func
ValidateDaemonSetUpdate
(
controller
,
oldC
ontroller
*
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
,
c
ontroller
.
Spec
.
Template
)
.
Prefix
(
"spec.template"
)
...
)
allErrs
=
append
(
allErrs
,
ValidateDaemonSetTemplateUpdate
(
controller
.
Spec
.
Template
,
oldC
ontroller
.
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
,
p
odTemplate
*
api
.
PodTemplateSpec
)
errs
.
ValidationErrorList
{
func
ValidateDaemonSetTemplateUpdate
(
podTemplate
,
oldP
odTemplate
*
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
,
j
ob
*
extensions
.
Job
)
errs
.
ValidationErrorList
{
func
ValidateJobUpdate
(
job
,
oldJ
ob
*
extensions
.
Job
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateObjectMetaUpdate
(
&
oldJob
.
ObjectMeta
,
&
job
.
ObjectMeta
)
.
Prefix
(
"metadata"
)
...
)
allErrs
=
append
(
allErrs
,
ValidateJobSpecUpdate
(
oldJob
.
Spec
,
j
ob
.
Spec
)
.
Prefix
(
"spec"
)
...
)
allErrs
=
append
(
allErrs
,
ValidateJobSpecUpdate
(
job
.
Spec
,
oldJ
ob
.
Spec
)
.
Prefix
(
"spec"
)
...
)
return
allErrs
}
func
ValidateJobUpdateStatus
(
oldJob
,
j
ob
*
extensions
.
Job
)
errs
.
ValidationErrorList
{
func
ValidateJobUpdateStatus
(
job
,
oldJ
ob
*
extensions
.
Job
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateObjectMetaUpdate
(
&
oldJob
.
ObjectMeta
,
&
job
.
ObjectMeta
)
.
Prefix
(
"metadata"
)
...
)
allErrs
=
append
(
allErrs
,
ValidateJobStatusUpdate
(
oldJob
.
Status
,
j
ob
.
Status
)
.
Prefix
(
"status"
)
...
)
allErrs
=
append
(
allErrs
,
ValidateJobStatusUpdate
(
job
.
Status
,
oldJ
ob
.
Status
)
.
Prefix
(
"status"
)
...
)
return
allErrs
}
func
ValidateJobSpecUpdate
(
oldSpec
,
s
pec
extensions
.
JobSpec
)
errs
.
ValidationErrorList
{
func
ValidateJobSpecUpdate
(
spec
,
oldS
pec
extensions
.
JobSpec
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
=
append
(
allErrs
,
ValidateJobSpec
(
&
spec
)
...
)
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateImmutableField
(
oldSpec
.
Completions
,
s
pec
.
Completions
,
"completions"
)
...
)
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateImmutableField
(
oldSpec
.
Selector
,
s
pec
.
Selector
,
"selector"
)
...
)
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateImmutableField
(
oldSpec
.
Template
,
s
pec
.
Template
,
"template"
)
...
)
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateImmutableField
(
spec
.
Completions
,
oldS
pec
.
Completions
,
"completions"
)
...
)
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateImmutableField
(
spec
.
Selector
,
oldS
pec
.
Selector
,
"selector"
)
...
)
allErrs
=
append
(
allErrs
,
apivalidation
.
ValidateImmutableField
(
spec
.
Template
,
oldS
pec
.
Template
,
"template"
)
...
)
return
allErrs
}
func
ValidateJobStatusUpdate
(
oldStatus
,
s
tatus
extensions
.
JobStatus
)
errs
.
ValidationErrorList
{
func
ValidateJobStatusUpdate
(
status
,
oldS
tatus
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
,
i
ngress
*
extensions
.
Ingress
)
errs
.
ValidationErrorList
{
func
ValidateIngressUpdate
(
ingress
,
oldI
ngress
*
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"
)
...
)
...
...
pkg/apis/extensions/validation/validation_test.go
View file @
447fe209
...
...
@@ -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
)
}
}
...
...
pkg/registry/controller/strategy.go
View file @
447fe209
...
...
@@ -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
(
o
ld
.
(
*
api
.
ReplicationController
),
obj
.
(
*
api
.
ReplicationController
))
updateErrorList
:=
validation
.
ValidateReplicationControllerUpdate
(
o
bj
.
(
*
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
(
o
ld
.
(
*
api
.
ReplicationController
),
obj
.
(
*
api
.
ReplicationController
))
return
validation
.
ValidateReplicationControllerStatusUpdate
(
o
bj
.
(
*
api
.
ReplicationController
),
old
.
(
*
api
.
ReplicationController
))
}
pkg/registry/daemonset/strategy.go
View file @
447fe209
...
...
@@ -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
(
o
ld
.
(
*
extensions
.
DaemonSet
),
obj
.
(
*
extensions
.
DaemonSet
))
updateErrorList
:=
validation
.
ValidateDaemonSetUpdate
(
o
bj
.
(
*
extensions
.
DaemonSet
),
old
.
(
*
extensions
.
DaemonSet
))
return
append
(
validationErrorList
,
updateErrorList
...
)
}
...
...
pkg/registry/deployment/strategy.go
View file @
447fe209
...
...
@@ -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
(
o
ld
.
(
*
extensions
.
Deployment
),
obj
.
(
*
extensions
.
Deployment
))
return
validation
.
ValidateDeploymentUpdate
(
o
bj
.
(
*
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
(
o
ld
.
(
*
extensions
.
Deployment
),
obj
.
(
*
extensions
.
Deployment
))
return
validation
.
ValidateDeploymentUpdate
(
o
bj
.
(
*
extensions
.
Deployment
),
old
.
(
*
extensions
.
Deployment
))
}
// DeploymentToSelectableFields returns a field set that represents the object.
...
...
pkg/registry/endpoint/strategy.go
View file @
447fe209
...
...
@@ -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
(
o
ld
.
(
*
api
.
Endpoints
),
obj
.
(
*
api
.
Endpoints
))
...
)
return
append
(
errorList
,
validation
.
ValidateEndpointsUpdate
(
o
bj
.
(
*
api
.
Endpoints
),
old
.
(
*
api
.
Endpoints
))
...
)
}
func
(
endpointsStrategy
)
AllowUnconditionalUpdate
()
bool
{
...
...
pkg/registry/ingress/strategy.go
View file @
447fe209
...
...
@@ -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
(
o
ld
.
(
*
extensions
.
Ingress
),
obj
.
(
*
extensions
.
Ingress
))
updateErrorList
:=
validation
.
ValidateIngressUpdate
(
o
bj
.
(
*
extensions
.
Ingress
),
old
.
(
*
extensions
.
Ingress
))
return
append
(
validationErrorList
,
updateErrorList
...
)
}
...
...
pkg/registry/job/strategy.go
View file @
447fe209
...
...
@@ -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
(
o
ld
.
(
*
extensions
.
Job
),
obj
.
(
*
extensions
.
Job
))
updateErrorList
:=
validation
.
ValidateJobUpdate
(
o
bj
.
(
*
extensions
.
Job
),
old
.
(
*
extensions
.
Job
))
return
append
(
validationErrorList
,
updateErrorList
...
)
}
...
...
pkg/registry/node/strategy.go
View file @
447fe209
...
...
@@ -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
(
o
ld
.
(
*
api
.
Node
),
obj
.
(
*
api
.
Node
))
...
)
return
append
(
errorList
,
validation
.
ValidateNodeUpdate
(
o
bj
.
(
*
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
(
o
ld
.
(
*
api
.
Node
),
obj
.
(
*
api
.
Node
))
return
validation
.
ValidateNodeUpdate
(
o
bj
.
(
*
api
.
Node
),
old
.
(
*
api
.
Node
))
}
// ResourceGetter is an interface for retrieving resources by ResourceLocation.
...
...
pkg/registry/secret/strategy.go
View file @
447fe209
...
...
@@ -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
(
o
ld
.
(
*
api
.
Secret
),
obj
.
(
*
api
.
Secret
))
return
validation
.
ValidateSecretUpdate
(
o
bj
.
(
*
api
.
Secret
),
old
.
(
*
api
.
Secret
))
}
func
(
strategy
)
AllowUnconditionalUpdate
()
bool
{
...
...
pkg/registry/service/rest.go
View file @
447fe209
...
...
@@ -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
,
s
ervice
);
len
(
errs
)
>
0
{
if
errs
:=
validation
.
ValidateServiceUpdate
(
service
,
oldS
ervice
);
len
(
errs
)
>
0
{
return
nil
,
false
,
errors
.
NewInvalid
(
"service"
,
service
.
Name
,
errs
)
}
...
...
pkg/registry/service/strategy.go
View file @
447fe209
...
...
@@ -68,7 +68,7 @@ func (svcStrategy) AllowCreateOnUpdate() bool {
}
func
(
svcStrategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
return
validation
.
ValidateServiceUpdate
(
o
ld
.
(
*
api
.
Service
),
obj
.
(
*
api
.
Service
))
return
validation
.
ValidateServiceUpdate
(
o
bj
.
(
*
api
.
Service
),
old
.
(
*
api
.
Service
))
}
func
(
svcStrategy
)
AllowUnconditionalUpdate
()
bool
{
...
...
pkg/registry/serviceaccount/strategy.go
View file @
447fe209
...
...
@@ -65,7 +65,7 @@ func cleanSecretReferences(serviceAccount *api.ServiceAccount) {
}
func
(
strategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
return
validation
.
ValidateServiceAccountUpdate
(
o
ld
.
(
*
api
.
ServiceAccount
),
obj
.
(
*
api
.
ServiceAccount
))
return
validation
.
ValidateServiceAccountUpdate
(
o
bj
.
(
*
api
.
ServiceAccount
),
old
.
(
*
api
.
ServiceAccount
))
}
func
(
strategy
)
AllowUnconditionalUpdate
()
bool
{
...
...
pkg/registry/thirdpartyresource/strategy.go
View file @
447fe209
...
...
@@ -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
(
o
ld
.
(
*
extensions
.
ThirdPartyResource
),
obj
.
(
*
extensions
.
ThirdPartyResource
))
return
validation
.
ValidateThirdPartyResourceUpdate
(
o
bj
.
(
*
extensions
.
ThirdPartyResource
),
old
.
(
*
extensions
.
ThirdPartyResource
))
}
func
(
strategy
)
AllowUnconditionalUpdate
()
bool
{
...
...
pkg/registry/thirdpartyresourcedata/strategy.go
View file @
447fe209
...
...
@@ -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
(
o
ld
.
(
*
extensions
.
ThirdPartyResourceData
),
obj
.
(
*
extensions
.
ThirdPartyResourceData
))
return
validation
.
ValidateThirdPartyResourceDataUpdate
(
o
bj
.
(
*
extensions
.
ThirdPartyResourceData
),
old
.
(
*
extensions
.
ThirdPartyResourceData
))
}
func
(
strategy
)
AllowUnconditionalUpdate
()
bool
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment