mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-01-04 23:17:50 +00:00
Merge pull request #44808 from shiywang/SemanticDeepEqual
Automatic merge from submit-queue (batch tested with PRs 44931, 44808) Update to use Semantic.DeepEqual in regsitry **What this PR does / why we need it**: **Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: fixes https://github.com/kubernetes/kubernetes/issues/43402 **Release note**: ``` NONE ``` /assign @janetkuo
This commit is contained in:
@@ -20,6 +20,7 @@ go_library(
|
||||
"//pkg/api:go_default_library",
|
||||
"//pkg/api/helper:go_default_library",
|
||||
"//pkg/api/validation:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/internalversion:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library",
|
||||
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
|
||||
|
||||
@@ -20,10 +20,10 @@ package replicationcontroller
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"reflect"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
apiequality "k8s.io/apimachinery/pkg/api/equality"
|
||||
"k8s.io/apimachinery/pkg/fields"
|
||||
"k8s.io/apimachinery/pkg/labels"
|
||||
"k8s.io/apimachinery/pkg/runtime"
|
||||
@@ -81,7 +81,7 @@ func (rcStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old runti
|
||||
// status its own object, and even if we don't, writes may be the result of a
|
||||
// read-update-write loop, so the contents of spec may not actually be the spec that
|
||||
// the controller has *seen*.
|
||||
if !reflect.DeepEqual(oldController.Spec, newController.Spec) {
|
||||
if !apiequality.Semantic.DeepEqual(oldController.Spec, newController.Spec) {
|
||||
newController.Generation = oldController.Generation + 1
|
||||
}
|
||||
}
|
||||
@@ -120,7 +120,7 @@ func (rcStrategy) ValidateUpdate(ctx genericapirequest.Context, obj, old runtime
|
||||
|
||||
switch {
|
||||
case strings.Contains(brokenField, "selector"):
|
||||
if !reflect.DeepEqual(oldRc.Spec.Selector, newRc.Spec.Selector) {
|
||||
if !apiequality.Semantic.DeepEqual(oldRc.Spec.Selector, newRc.Spec.Selector) {
|
||||
errs = append(errs, field.Invalid(field.NewPath("spec").Child("selector"), newRc.Spec.Selector, "cannot update non-convertible selector"))
|
||||
}
|
||||
default:
|
||||
|
||||
Reference in New Issue
Block a user