mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
Merge pull request #59249 from hanxiaoshuai/fixtodo0202
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>. fix todo: Move isDecremented to pkg/apis/core/validation **What this PR does / why we need it**: fix todo: Move isDecremented in "k8s.io/kubernetes/pkg/apis/core/validation" **Which issue(s) this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close the issue(s) when PR gets merged)*: Fixes # **Special notes for your reviewer**: 2. If no release note is required, just write "NONE". --> ```release-note NONE ```
This commit is contained in:
commit
84bfc7ada5
@ -4966,3 +4966,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
|
||||
}
|
||||
|
@ -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 isDecremented(ds.Status.CollisionCount, oldDS.Status.CollisionCount) {
|
||||
if apivalidation.IsDecremented(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 isDecremented(update.Status.CollisionCount, old.Status.CollisionCount) {
|
||||
if apivalidation.IsDecremented(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"))...)
|
||||
|
Loading…
Reference in New Issue
Block a user