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
aa892b71
Commit
aa892b71
authored
Jun 08, 2015
by
Jason Sommer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Replace meta with new
parent
d59a8ff7
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
17 deletions
+17
-17
validation.go
pkg/api/validation/validation.go
+17
-17
No files found.
pkg/api/validation/validation.go
View file @
aa892b71
...
...
@@ -239,40 +239,40 @@ func ValidateObjectMeta(meta *api.ObjectMeta, requiresNamespace bool, nameFn Val
}
// ValidateObjectMetaUpdate validates an object's metadata when updated
func
ValidateObjectMetaUpdate
(
meta
,
old
*
api
.
ObjectMeta
)
errs
.
ValidationErrorList
{
func
ValidateObjectMetaUpdate
(
new
,
old
*
api
.
ObjectMeta
)
errs
.
ValidationErrorList
{
allErrs
:=
errs
.
ValidationErrorList
{}
// in the event it is left empty, set it, to allow clients more flexibility
if
len
(
meta
.
UID
)
==
0
{
meta
.
UID
=
old
.
UID
if
len
(
new
.
UID
)
==
0
{
new
.
UID
=
old
.
UID
}
// ignore changes to timestamp
if
old
.
CreationTimestamp
.
IsZero
()
{
old
.
CreationTimestamp
=
meta
.
CreationTimestamp
old
.
CreationTimestamp
=
new
.
CreationTimestamp
}
else
{
meta
.
CreationTimestamp
=
old
.
CreationTimestamp
new
.
CreationTimestamp
=
old
.
CreationTimestamp
}
// Reject updates that don't specify a resource version
if
meta
.
ResourceVersion
==
""
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"resourceVersion"
,
meta
.
ResourceVersion
,
"resourceVersion must be specified for an update"
))
if
new
.
ResourceVersion
==
""
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"resourceVersion"
,
new
.
ResourceVersion
,
"resourceVersion must be specified for an update"
))
}
if
old
.
Name
!=
meta
.
Name
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"name"
,
meta
.
Name
,
"field is immutable"
))
if
old
.
Name
!=
new
.
Name
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"name"
,
new
.
Name
,
"field is immutable"
))
}
if
old
.
Namespace
!=
meta
.
Namespace
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"namespace"
,
meta
.
Namespace
,
"field is immutable"
))
if
old
.
Namespace
!=
new
.
Namespace
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"namespace"
,
new
.
Namespace
,
"field is immutable"
))
}
if
old
.
UID
!=
meta
.
UID
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"uid"
,
meta
.
UID
,
"field is immutable"
))
if
old
.
UID
!=
new
.
UID
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"uid"
,
new
.
UID
,
"field is immutable"
))
}
if
old
.
CreationTimestamp
!=
meta
.
CreationTimestamp
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"creationTimestamp"
,
meta
.
CreationTimestamp
,
"field is immutable"
))
if
old
.
CreationTimestamp
!=
new
.
CreationTimestamp
{
allErrs
=
append
(
allErrs
,
errs
.
NewFieldInvalid
(
"creationTimestamp"
,
new
.
CreationTimestamp
,
"field is immutable"
))
}
allErrs
=
append
(
allErrs
,
ValidateLabels
(
meta
.
Labels
,
"labels"
)
...
)
allErrs
=
append
(
allErrs
,
ValidateAnnotations
(
meta
.
Annotations
,
"annotations"
)
...
)
allErrs
=
append
(
allErrs
,
ValidateLabels
(
new
.
Labels
,
"labels"
)
...
)
allErrs
=
append
(
allErrs
,
ValidateAnnotations
(
new
.
Annotations
,
"annotations"
)
...
)
return
allErrs
}
...
...
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