Skip to content

Commit ce8ac62

Browse files
committed
Replace diff.ObjectDiff (removed) with cmp.Diff
1 parent 3a84f71 commit ce8ac62

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ require (
99
github.com/evanphx/json-patch v5.9.0+incompatible
1010
github.com/fsnotify/fsnotify v1.9.0
1111
github.com/golang/mock v1.6.0
12+
github.com/google/go-cmp v0.7.0
1213
github.com/kubernetes-csi/csi-lib-utils v0.22.0
1314
github.com/kubernetes-csi/csi-test/v5 v5.3.1
1415
github.com/kubernetes-csi/external-snapshotter/client/v8 v8.2.0
@@ -54,7 +55,6 @@ require (
5455
github.com/golang/protobuf v1.5.4 // indirect
5556
github.com/google/cel-go v0.26.0 // indirect
5657
github.com/google/gnostic-models v0.7.0 // indirect
57-
github.com/google/go-cmp v0.7.0 // indirect
5858
github.com/google/uuid v1.6.0 // indirect
5959
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0 // indirect
6060
github.com/grpc-ecosystem/grpc-gateway/v2 v2.26.3 // indirect

pkg/common-controller/framework_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ import (
3434
"time"
3535

3636
jsonpatch "github.com/evanphx/json-patch"
37+
"github.com/google/go-cmp/cmp"
3738
crdv1beta2 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumegroupsnapshot/v1beta2"
3839
crdv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
3940
clientset "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned"
@@ -50,7 +51,6 @@ import (
5051
"k8s.io/apimachinery/pkg/labels"
5152
"k8s.io/apimachinery/pkg/runtime"
5253
"k8s.io/apimachinery/pkg/types"
53-
"k8s.io/apimachinery/pkg/util/diff"
5454
"k8s.io/apimachinery/pkg/util/wait"
5555
"k8s.io/apimachinery/pkg/watch"
5656
coreinformers "k8s.io/client-go/informers"
@@ -789,7 +789,7 @@ func (r *snapshotReactor) checkContents(expectedContents []*crdv1.VolumeSnapshot
789789
if !reflect.DeepEqual(expectedMap, gotMap) {
790790
// Print ugly but useful diff of expected and received objects for
791791
// easier debugging.
792-
return fmt.Errorf("content check failed [A-expected, B-got]: %s", diff.ObjectDiff(expectedMap, gotMap))
792+
return fmt.Errorf("content check failed [A-expected, B-got]: %s", cmp.Diff(expectedMap, gotMap))
793793
}
794794
return nil
795795
}
@@ -828,7 +828,7 @@ func (r *snapshotReactor) checkGroupContents(expectedGroupContents []*crdv1beta2
828828
if !reflect.DeepEqual(expectedMap, gotMap) {
829829
// Print ugly but useful diff of expected and received objects for
830830
// easier debugging.
831-
return fmt.Errorf("content check failed [A-expected, B-got]: %s", diff.ObjectDiff(expectedMap, gotMap))
831+
return fmt.Errorf("content check failed [A-expected, B-got]: %s", cmp.Diff(expectedMap, gotMap))
832832
}
833833
return nil
834834
}
@@ -863,7 +863,7 @@ func (r *snapshotReactor) checkSnapshots(expectedSnapshots []*crdv1.VolumeSnapsh
863863
if !reflect.DeepEqual(expectedMap, gotMap) {
864864
// Print ugly but useful diff of expected and received objects for
865865
// easier debugging.
866-
return fmt.Errorf("snapshot check failed [A-expected, B-got result]: %s", diff.ObjectDiff(expectedMap, gotMap))
866+
return fmt.Errorf("snapshot check failed [A-expected, B-got result]: %s", cmp.Diff(expectedMap, gotMap))
867867
}
868868
return nil
869869
}
@@ -898,7 +898,7 @@ func (r *snapshotReactor) checkGroupSnapshots(expectedGroupSnapshots []*crdv1bet
898898
if !reflect.DeepEqual(expectedMap, gotMap) {
899899
// Print ugly but useful diff of expected and received objects for
900900
// easier debugging.
901-
return fmt.Errorf("snapshot check failed [A-expected, B-got result]: %s", diff.ObjectDiff(expectedMap, gotMap))
901+
return fmt.Errorf("snapshot check failed [A-expected, B-got result]: %s", cmp.Diff(expectedMap, gotMap))
902902
}
903903
return nil
904904
}
@@ -1762,7 +1762,7 @@ func testUpdateSnapshotErrorStatus(ctrl *csiSnapshotCommonController, reactor *s
17621762
return fmt.Errorf("update snapshot status failed: expected: %v but got nil", expected)
17631763
}
17641764
if expected != nil && got != nil && !reflect.DeepEqual(expected, got) {
1765-
return fmt.Errorf("update snapshot status failed [A-expected, B-got]: %s", diff.ObjectDiff(expected, got))
1765+
return fmt.Errorf("update snapshot status failed [A-expected, B-got]: %s", cmp.Diff(expected, got))
17661766
}
17671767
return nil
17681768
}

pkg/sidecar-controller/framework_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ import (
2727
"time"
2828

2929
jsonpatch "github.com/evanphx/json-patch"
30+
"github.com/google/go-cmp/cmp"
3031
crdv1 "github.com/kubernetes-csi/external-snapshotter/client/v8/apis/volumesnapshot/v1"
3132
clientset "github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned"
3233
"github.com/kubernetes-csi/external-snapshotter/client/v8/clientset/versioned/fake"
@@ -39,7 +40,6 @@ import (
3940
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
4041
"k8s.io/apimachinery/pkg/runtime"
4142
"k8s.io/apimachinery/pkg/types"
42-
"k8s.io/apimachinery/pkg/util/diff"
4343
"k8s.io/apimachinery/pkg/util/wait"
4444
"k8s.io/apimachinery/pkg/watch"
4545
"k8s.io/client-go/kubernetes"
@@ -359,7 +359,7 @@ func (r *snapshotReactor) checkContents(expectedContents []*crdv1.VolumeSnapshot
359359
if !reflect.DeepEqual(expectedMap, gotMap) {
360360
// Print ugly but useful diff of expected and received objects for
361361
// easier debugging.
362-
return fmt.Errorf("content check failed [A-expected, B-got]: %s", diff.ObjectDiff(expectedMap, gotMap))
362+
return fmt.Errorf("content check failed [A-expected, B-got]: %s", cmp.Diff(expectedMap, gotMap))
363363
}
364364
return nil
365365
}

0 commit comments

Comments
 (0)