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
5d4f1cf8
Commit
5d4f1cf8
authored
Apr 08, 2015
by
Brendan Burns
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Validate in addition to ValidateUpdate to validation for most resources.
parent
e44ec497
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
20 additions
and
8 deletions
+20
-8
validation.go
pkg/api/validation/validation.go
+1
-0
rest.go
pkg/registry/controller/rest.go
+3
-1
rest.go
pkg/registry/endpoint/rest.go
+2
-1
rest.go
pkg/registry/minion/rest.go
+2
-1
rest.go
pkg/registry/namespace/rest.go
+2
-1
rest.go
pkg/registry/persistentvolume/rest.go
+2
-1
rest.go
pkg/registry/persistentvolumeclaim/rest.go
+2
-1
etcd_test.go
pkg/registry/pod/etcd/etcd_test.go
+2
-0
rest.go
pkg/registry/pod/rest.go
+2
-1
rest.go
pkg/registry/resourcequota/rest.go
+2
-1
No files found.
pkg/api/validation/validation.go
View file @
5d4f1cf8
...
@@ -1225,6 +1225,7 @@ func validateFinalizerName(stringValue string) errs.ValidationErrorList {
...
@@ -1225,6 +1225,7 @@ func validateFinalizerName(stringValue string) errs.ValidationErrorList {
// ValidateNamespaceUpdate tests to make sure a namespace update can be applied.
// ValidateNamespaceUpdate tests to make sure a namespace update can be applied.
// newNamespace is updated with fields that cannot be changed
// newNamespace is updated with fields that cannot be changed
// TODO The syntax here is the reverse of the (old, new) pattern in most other validation. Fix this.
func
ValidateNamespaceUpdate
(
newNamespace
*
api
.
Namespace
,
oldNamespace
*
api
.
Namespace
)
errs
.
ValidationErrorList
{
func
ValidateNamespaceUpdate
(
newNamespace
*
api
.
Namespace
,
oldNamespace
*
api
.
Namespace
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
:=
errs
.
ValidationErrorList
{}
allErrs
=
append
(
allErrs
,
ValidateObjectMetaUpdate
(
&
oldNamespace
.
ObjectMeta
,
&
newNamespace
.
ObjectMeta
)
.
Prefix
(
"metadata"
)
...
)
allErrs
=
append
(
allErrs
,
ValidateObjectMetaUpdate
(
&
oldNamespace
.
ObjectMeta
,
&
newNamespace
.
ObjectMeta
)
.
Prefix
(
"metadata"
)
...
)
...
...
pkg/registry/controller/rest.go
View file @
5d4f1cf8
...
@@ -71,7 +71,9 @@ func (rcStrategy) AllowCreateOnUpdate() bool {
...
@@ -71,7 +71,9 @@ 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
{
return
validation
.
ValidateReplicationControllerUpdate
(
old
.
(
*
api
.
ReplicationController
),
obj
.
(
*
api
.
ReplicationController
))
validationErrorList
:=
validation
.
ValidateReplicationController
(
obj
.
(
*
api
.
ReplicationController
))
updateErrorList
:=
validation
.
ValidateReplicationControllerUpdate
(
old
.
(
*
api
.
ReplicationController
),
obj
.
(
*
api
.
ReplicationController
))
return
append
(
validationErrorList
,
updateErrorList
...
)
}
}
// ControllerToSelectableFields returns a label set that represents the object.
// ControllerToSelectableFields returns a label set that represents the object.
...
...
pkg/registry/endpoint/rest.go
View file @
5d4f1cf8
...
@@ -69,7 +69,8 @@ func (endpointsStrategy) AllowCreateOnUpdate() bool {
...
@@ -69,7 +69,8 @@ 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
{
return
validation
.
ValidateEndpointsUpdate
(
old
.
(
*
api
.
Endpoints
),
obj
.
(
*
api
.
Endpoints
))
errorList
:=
validation
.
ValidateEndpoints
(
obj
.
(
*
api
.
Endpoints
))
return
append
(
errorList
,
validation
.
ValidateEndpointsUpdate
(
old
.
(
*
api
.
Endpoints
),
obj
.
(
*
api
.
Endpoints
))
...
)
}
}
// MatchEndpoints returns a generic matcher for a given label and field selector.
// MatchEndpoints returns a generic matcher for a given label and field selector.
...
...
pkg/registry/minion/rest.go
View file @
5d4f1cf8
...
@@ -74,7 +74,8 @@ func (nodeStrategy) Validate(ctx api.Context, obj runtime.Object) fielderrors.Va
...
@@ -74,7 +74,8 @@ func (nodeStrategy) Validate(ctx api.Context, obj runtime.Object) fielderrors.Va
// ValidateUpdate is the default update validation for an end user.
// 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
{
return
validation
.
ValidateMinionUpdate
(
old
.
(
*
api
.
Node
),
obj
.
(
*
api
.
Node
))
errorList
:=
validation
.
ValidateMinion
(
obj
.
(
*
api
.
Node
))
return
append
(
errorList
,
validation
.
ValidateMinionUpdate
(
old
.
(
*
api
.
Node
),
obj
.
(
*
api
.
Node
))
...
)
}
}
// ResourceGetter is an interface for retrieving resources by ResourceLocation.
// ResourceGetter is an interface for retrieving resources by ResourceLocation.
...
...
pkg/registry/namespace/rest.go
View file @
5d4f1cf8
...
@@ -89,7 +89,8 @@ func (namespaceStrategy) AllowCreateOnUpdate() bool {
...
@@ -89,7 +89,8 @@ func (namespaceStrategy) AllowCreateOnUpdate() bool {
// ValidateUpdate is the default update validation for an end user.
// ValidateUpdate is the default update validation for an end user.
func
(
namespaceStrategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
func
(
namespaceStrategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
return
validation
.
ValidateNamespaceUpdate
(
obj
.
(
*
api
.
Namespace
),
old
.
(
*
api
.
Namespace
))
errorList
:=
validation
.
ValidateNamespace
(
obj
.
(
*
api
.
Namespace
))
return
append
(
errorList
,
validation
.
ValidateNamespaceUpdate
(
obj
.
(
*
api
.
Namespace
),
old
.
(
*
api
.
Namespace
))
...
)
}
}
type
namespaceStatusStrategy
struct
{
type
namespaceStatusStrategy
struct
{
...
...
pkg/registry/persistentvolume/rest.go
View file @
5d4f1cf8
...
@@ -65,7 +65,8 @@ func (persistentvolumeStrategy) PrepareForUpdate(obj, old runtime.Object) {
...
@@ -65,7 +65,8 @@ func (persistentvolumeStrategy) PrepareForUpdate(obj, old runtime.Object) {
}
}
func
(
persistentvolumeStrategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
func
(
persistentvolumeStrategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
return
validation
.
ValidatePersistentVolumeUpdate
(
obj
.
(
*
api
.
PersistentVolume
),
old
.
(
*
api
.
PersistentVolume
))
errorList
:=
validation
.
ValidatePersistentVolume
(
obj
.
(
*
api
.
PersistentVolume
))
return
append
(
errorList
,
validation
.
ValidatePersistentVolumeUpdate
(
obj
.
(
*
api
.
PersistentVolume
),
old
.
(
*
api
.
PersistentVolume
))
...
)
}
}
type
persistentvolumeStatusStrategy
struct
{
type
persistentvolumeStatusStrategy
struct
{
...
...
pkg/registry/persistentvolumeclaim/rest.go
View file @
5d4f1cf8
...
@@ -65,7 +65,8 @@ func (persistentvolumeclaimStrategy) PrepareForUpdate(obj, old runtime.Object) {
...
@@ -65,7 +65,8 @@ func (persistentvolumeclaimStrategy) PrepareForUpdate(obj, old runtime.Object) {
}
}
func
(
persistentvolumeclaimStrategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
func
(
persistentvolumeclaimStrategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
return
validation
.
ValidatePersistentVolumeClaimUpdate
(
obj
.
(
*
api
.
PersistentVolumeClaim
),
old
.
(
*
api
.
PersistentVolumeClaim
))
errorList
:=
validation
.
ValidatePersistentVolumeClaim
(
obj
.
(
*
api
.
PersistentVolumeClaim
))
return
append
(
errorList
,
validation
.
ValidatePersistentVolumeClaimUpdate
(
obj
.
(
*
api
.
PersistentVolumeClaim
),
old
.
(
*
api
.
PersistentVolumeClaim
))
...
)
}
}
type
persistentvolumeclaimStatusStrategy
struct
{
type
persistentvolumeclaimStatusStrategy
struct
{
...
...
pkg/registry/pod/etcd/etcd_test.go
View file @
5d4f1cf8
...
@@ -1062,6 +1062,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
...
@@ -1062,6 +1062,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
Host
:
"machine"
,
Host
:
"machine"
,
Containers
:
[]
api
.
Container
{
Containers
:
[]
api
.
Container
{
{
{
Name
:
"foobar"
,
Image
:
"foo:v1"
,
Image
:
"foo:v1"
,
},
},
},
},
...
@@ -1080,6 +1081,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
...
@@ -1080,6 +1081,7 @@ func TestEtcdUpdateScheduled(t *testing.T) {
Host
:
"machine"
,
Host
:
"machine"
,
Containers
:
[]
api
.
Container
{
Containers
:
[]
api
.
Container
{
{
{
Name
:
"foobar"
,
Image
:
"foo:v2"
,
Image
:
"foo:v2"
,
ImagePullPolicy
:
api
.
PullIfNotPresent
,
ImagePullPolicy
:
api
.
PullIfNotPresent
,
TerminationMessagePath
:
api
.
TerminationMessagePathDefault
,
TerminationMessagePath
:
api
.
TerminationMessagePathDefault
,
...
...
pkg/registry/pod/rest.go
View file @
5d4f1cf8
...
@@ -79,7 +79,8 @@ func (podStrategy) AllowCreateOnUpdate() bool {
...
@@ -79,7 +79,8 @@ func (podStrategy) AllowCreateOnUpdate() bool {
// ValidateUpdate is the default update validation for an end user.
// ValidateUpdate is the default update validation for an end user.
func
(
podStrategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
func
(
podStrategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
return
validation
.
ValidatePodUpdate
(
obj
.
(
*
api
.
Pod
),
old
.
(
*
api
.
Pod
))
errorList
:=
validation
.
ValidatePod
(
obj
.
(
*
api
.
Pod
))
return
append
(
errorList
,
validation
.
ValidatePodUpdate
(
obj
.
(
*
api
.
Pod
),
old
.
(
*
api
.
Pod
))
...
)
}
}
// CheckGracefulDelete allows a pod to be gracefully deleted.
// CheckGracefulDelete allows a pod to be gracefully deleted.
...
...
pkg/registry/resourcequota/rest.go
View file @
5d4f1cf8
...
@@ -69,7 +69,8 @@ func (resourcequotaStrategy) AllowCreateOnUpdate() bool {
...
@@ -69,7 +69,8 @@ func (resourcequotaStrategy) AllowCreateOnUpdate() bool {
// ValidateUpdate is the default update validation for an end user.
// ValidateUpdate is the default update validation for an end user.
func
(
resourcequotaStrategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
func
(
resourcequotaStrategy
)
ValidateUpdate
(
ctx
api
.
Context
,
obj
,
old
runtime
.
Object
)
fielderrors
.
ValidationErrorList
{
return
validation
.
ValidateResourceQuotaUpdate
(
obj
.
(
*
api
.
ResourceQuota
),
old
.
(
*
api
.
ResourceQuota
))
errorList
:=
validation
.
ValidateResourceQuota
(
obj
.
(
*
api
.
ResourceQuota
))
return
append
(
errorList
,
validation
.
ValidateResourceQuotaUpdate
(
obj
.
(
*
api
.
ResourceQuota
),
old
.
(
*
api
.
ResourceQuota
))
...
)
}
}
type
resourcequotaStatusStrategy
struct
{
type
resourcequotaStatusStrategy
struct
{
...
...
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