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
e7076025
Commit
e7076025
authored
Feb 02, 2018
by
hangaoshuai
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fix todo: Move isDecremented to pkg/apis/core/validation
parent
f3942e7d
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
12 additions
and
13 deletions
+12
-13
validation.go
pkg/apis/core/validation/validation.go
+10
-0
validation.go
pkg/apis/extensions/validation/validation.go
+2
-13
No files found.
pkg/apis/core/validation/validation.go
View file @
e7076025
...
...
@@ -4939,3 +4939,13 @@ func ValidateCIDR(cidr string) (*net.IPNet, error) {
}
return
net
,
nil
}
func
IsDecremented
(
update
,
old
*
int32
)
bool
{
if
update
==
nil
&&
old
!=
nil
{
return
true
}
if
update
==
nil
||
old
==
nil
{
return
false
}
return
*
update
<
*
old
}
pkg/apis/extensions/validation/validation.go
View file @
e7076025
...
...
@@ -96,7 +96,7 @@ func validateDaemonSetStatus(status *extensions.DaemonSetStatus, fldPath *field.
func
ValidateDaemonSetStatusUpdate
(
ds
,
oldDS
*
extensions
.
DaemonSet
)
field
.
ErrorList
{
allErrs
:=
apivalidation
.
ValidateObjectMetaUpdate
(
&
ds
.
ObjectMeta
,
&
oldDS
.
ObjectMeta
,
field
.
NewPath
(
"metadata"
))
allErrs
=
append
(
allErrs
,
validateDaemonSetStatus
(
&
ds
.
Status
,
field
.
NewPath
(
"status"
))
...
)
if
i
sDecremented
(
ds
.
Status
.
CollisionCount
,
oldDS
.
Status
.
CollisionCount
)
{
if
apivalidation
.
I
sDecremented
(
ds
.
Status
.
CollisionCount
,
oldDS
.
Status
.
CollisionCount
)
{
value
:=
int32
(
0
)
if
ds
.
Status
.
CollisionCount
!=
nil
{
value
=
*
ds
.
Status
.
CollisionCount
...
...
@@ -341,7 +341,7 @@ func ValidateDeploymentStatusUpdate(update, old *extensions.Deployment) field.Er
allErrs
:=
apivalidation
.
ValidateObjectMetaUpdate
(
&
update
.
ObjectMeta
,
&
old
.
ObjectMeta
,
field
.
NewPath
(
"metadata"
))
fldPath
:=
field
.
NewPath
(
"status"
)
allErrs
=
append
(
allErrs
,
ValidateDeploymentStatus
(
&
update
.
Status
,
fldPath
)
...
)
if
i
sDecremented
(
update
.
Status
.
CollisionCount
,
old
.
Status
.
CollisionCount
)
{
if
apivalidation
.
I
sDecremented
(
update
.
Status
.
CollisionCount
,
old
.
Status
.
CollisionCount
)
{
value
:=
int32
(
0
)
if
update
.
Status
.
CollisionCount
!=
nil
{
value
=
*
update
.
Status
.
CollisionCount
...
...
@@ -351,17 +351,6 @@ func ValidateDeploymentStatusUpdate(update, old *extensions.Deployment) field.Er
return
allErrs
}
// TODO: Move in "k8s.io/kubernetes/pkg/apis/core/validation"
func
isDecremented
(
update
,
old
*
int32
)
bool
{
if
update
==
nil
&&
old
!=
nil
{
return
true
}
if
update
==
nil
||
old
==
nil
{
return
false
}
return
*
update
<
*
old
}
func
ValidateDeployment
(
obj
*
extensions
.
Deployment
)
field
.
ErrorList
{
allErrs
:=
apivalidation
.
ValidateObjectMeta
(
&
obj
.
ObjectMeta
,
true
,
ValidateDeploymentName
,
field
.
NewPath
(
"metadata"
))
allErrs
=
append
(
allErrs
,
ValidateDeploymentSpec
(
&
obj
.
Spec
,
field
.
NewPath
(
"spec"
))
...
)
...
...
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