Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to use Semantic.DeepEqual in regsitry #44808

Merged
merged 1 commit into from
Apr 26, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/registry/apps/petset/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ go_library(
"//pkg/api:go_default_library",
"//pkg/apis/apps:go_default_library",
"//pkg/apis/apps/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
Expand Down
4 changes: 2 additions & 2 deletions pkg/registry/apps/petset/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package petset

import (
"fmt"
"reflect"

apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -73,7 +73,7 @@ func (statefulSetStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj,
// Any changes to the spec increment the generation number, any changes to the
// status should reflect the generation number of the corresponding object.
// See metav1.ObjectMeta description for more information on Generation.
if !reflect.DeepEqual(oldStatefulSet.Spec, newStatefulSet.Spec) {
if !apiequality.Semantic.DeepEqual(oldStatefulSet.Spec, newStatefulSet.Spec) {
newStatefulSet.Generation = oldStatefulSet.Generation + 1
}

Expand Down
1 change: 1 addition & 0 deletions pkg/registry/core/replicationcontroller/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
6 changes: 3 additions & 3 deletions pkg/registry/core/replicationcontroller/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}
}
Expand Down Expand Up @@ -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:
Expand Down
1 change: 1 addition & 0 deletions pkg/registry/extensions/deployment/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ go_library(
"//pkg/api:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//pkg/apis/extensions/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",
Expand Down
6 changes: 3 additions & 3 deletions pkg/registry/extensions/deployment/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package deployment

import (
"fmt"
"reflect"

apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -86,8 +86,8 @@ func (deploymentStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, o
// Spec updates bump the generation so that we can distinguish between
// scaling events and template changes, annotation updates bump the generation
// because annotations are copied from deployments to their replica sets.
if !reflect.DeepEqual(newDeployment.Spec, oldDeployment.Spec) ||
!reflect.DeepEqual(newDeployment.Annotations, oldDeployment.Annotations) {
if !apiequality.Semantic.DeepEqual(newDeployment.Spec, oldDeployment.Spec) ||
!apiequality.Semantic.DeepEqual(newDeployment.Annotations, oldDeployment.Annotations) {
newDeployment.Generation = oldDeployment.Generation + 1
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/registry/extensions/ingress/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ go_library(
"//pkg/api:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//pkg/apis/extensions/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
Expand Down
4 changes: 2 additions & 2 deletions pkg/registry/extensions/ingress/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package ingress

import (
"fmt"
"reflect"

apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -66,7 +66,7 @@ func (ingressStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj, old
// Any changes to the spec increment the generation number, any changes to the
// status should reflect the generation number of the corresponding object.
// See metav1.ObjectMeta description for more information on Generation.
if !reflect.DeepEqual(oldIngress.Spec, newIngress.Spec) {
if !apiequality.Semantic.DeepEqual(oldIngress.Spec, newIngress.Spec) {
newIngress.Generation = oldIngress.Generation + 1
}

Expand Down
1 change: 1 addition & 0 deletions pkg/registry/extensions/networkpolicy/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ go_library(
"//pkg/api:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//pkg/apis/extensions/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
Expand Down
4 changes: 2 additions & 2 deletions pkg/registry/extensions/networkpolicy/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package networkpolicy

import (
"fmt"
"reflect"

apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -61,7 +61,7 @@ func (networkPolicyStrategy) PrepareForUpdate(ctx genericapirequest.Context, obj
// Any changes to the spec increment the generation number, any changes to the
// status should reflect the generation number of the corresponding object.
// See metav1.ObjectMeta description for more information on Generation.
if !reflect.DeepEqual(oldNetworkPolicy.Spec, newNetworkPolicy.Spec) {
if !apiequality.Semantic.DeepEqual(oldNetworkPolicy.Spec, newNetworkPolicy.Spec) {
newNetworkPolicy.Generation = oldNetworkPolicy.Generation + 1
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/registry/extensions/replicaset/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ go_library(
"//pkg/api:go_default_library",
"//pkg/apis/extensions:go_default_library",
"//pkg/apis/extensions/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",
Expand Down
4 changes: 2 additions & 2 deletions pkg/registry/extensions/replicaset/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ package replicaset

import (
"fmt"
"reflect"
"strconv"

apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -80,7 +80,7 @@ func (rsStrategy) 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 ReplicaSet has *seen*.
if !reflect.DeepEqual(oldRS.Spec, newRS.Spec) {
if !apiequality.Semantic.DeepEqual(oldRS.Spec, newRS.Spec) {
newRS.Generation = oldRS.Generation + 1
}
}
Expand Down
1 change: 1 addition & 0 deletions pkg/registry/policy/poddisruptionbudget/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ go_library(
"//pkg/api:go_default_library",
"//pkg/apis/policy:go_default_library",
"//pkg/apis/policy/validation:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/api/equality:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/fields:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/labels:go_default_library",
"//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library",
Expand Down
4 changes: 2 additions & 2 deletions pkg/registry/policy/poddisruptionbudget/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ package poddisruptionbudget

import (
"fmt"
"reflect"

apiequality "k8s.io/apimachinery/pkg/api/equality"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/apimachinery/pkg/runtime"
Expand Down Expand Up @@ -66,7 +66,7 @@ func (podDisruptionBudgetStrategy) PrepareForUpdate(ctx genericapirequest.Contex
// Any changes to the spec increment the generation number, any changes to the
// status should reflect the generation number of the corresponding object.
// See metav1.ObjectMeta description for more information on Generation.
if !reflect.DeepEqual(oldPodDisruptionBudget.Spec, newPodDisruptionBudget.Spec) {
if !apiequality.Semantic.DeepEqual(oldPodDisruptionBudget.Spec, newPodDisruptionBudget.Spec) {
newPodDisruptionBudget.Generation = oldPodDisruptionBudget.Generation + 1
}
}
Expand Down