Skip to content

Commit cf1ef1f

Browse files
committed
Compartmentalize spew more
1 parent 50998de commit cf1ef1f

File tree

5 files changed

+10
-15
lines changed

5 files changed

+10
-15
lines changed

staging/publishing/import-restrictions.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
- "./staging/src/k8s.io/code-generator/examples"
5555
- "./staging/src/k8s.io/code-generator/cmd/defaulter-gen/output_tests"
5656
allowedImports:
57+
- k8s.io/apimachinery
5758
- k8s.io/gengo/v2
5859
- k8s.io/code-generator
5960
- k8s.io/kube-openapi

staging/src/k8s.io/code-generator/cmd/deepcopy-gen/output_tests/output_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,9 @@ import (
2121
"reflect"
2222
"testing"
2323

24-
"github.com/davecgh/go-spew/spew"
25-
"github.com/google/gofuzz"
24+
fuzz "github.com/google/gofuzz"
2625

26+
"k8s.io/apimachinery/pkg/util/dump"
2727
"k8s.io/code-generator/cmd/deepcopy-gen/output_tests/aliases"
2828
"k8s.io/code-generator/cmd/deepcopy-gen/output_tests/builtins"
2929
"k8s.io/code-generator/cmd/deepcopy-gen/output_tests/interfaces"
@@ -60,19 +60,19 @@ func TestWithValueFuzzer(t *testing.T) {
6060
reflectCopy := ReflectDeepCopy(original)
6161

6262
if !reflect.DeepEqual(original, reflectCopy) {
63-
t.Errorf("original and reflectCopy are different:\n\n original = %s\n\n jsonCopy = %s", spew.Sdump(original), spew.Sdump(reflectCopy))
63+
t.Errorf("original and reflectCopy are different:\n\n original = %s\n\n jsonCopy = %s", dump.Pretty(original), dump.Pretty(reflectCopy))
6464
}
6565

6666
deepCopy := reflect.ValueOf(original).MethodByName("DeepCopy").Call(nil)[0].Interface()
6767

6868
if !reflect.DeepEqual(original, deepCopy) {
69-
t.Fatalf("original and deepCopy are different:\n\n original = %s\n\n deepCopy() = %s", spew.Sdump(original), spew.Sdump(deepCopy))
69+
t.Fatalf("original and deepCopy are different:\n\n original = %s\n\n deepCopy() = %s", dump.Pretty(original), dump.Pretty(deepCopy))
7070
}
7171

7272
ValueFuzz(original)
7373

7474
if !reflect.DeepEqual(reflectCopy, deepCopy) {
75-
t.Fatalf("reflectCopy and deepCopy are different:\n\n origin = %s\n\n jsonCopy() = %s", spew.Sdump(original), spew.Sdump(deepCopy))
75+
t.Fatalf("reflectCopy and deepCopy are different:\n\n origin = %s\n\n jsonCopy() = %s", dump.Pretty(original), dump.Pretty(deepCopy))
7676
}
7777
}
7878
})

staging/src/k8s.io/code-generator/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ go 1.23.0
77
godebug default=go1.23
88

99
require (
10-
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
1110
github.com/gogo/protobuf v1.3.2
1211
github.com/google/gnostic-models v0.6.8
1312
github.com/google/go-cmp v0.6.0
@@ -22,6 +21,7 @@ require (
2221
)
2322

2423
require (
24+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2525
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
2626
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
2727
github.com/go-logr/logr v1.4.2 // indirect

staging/src/k8s.io/endpointslice/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ go 1.23.0
77
godebug default=go1.23
88

99
require (
10-
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
1110
github.com/google/go-cmp v0.6.0
1211
github.com/stretchr/testify v1.9.0
1312
k8s.io/api v0.0.0
@@ -22,6 +21,7 @@ require (
2221
github.com/beorn7/perks v1.0.1 // indirect
2322
github.com/blang/semver/v4 v4.0.0 // indirect
2423
github.com/cespare/xxhash/v2 v2.3.0 // indirect
24+
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
2525
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
2626
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
2727
github.com/go-logr/logr v1.4.2 // indirect

staging/src/k8s.io/endpointslice/util/controller_utils.go

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ import (
2424
"reflect"
2525
"sort"
2626

27-
"github.com/davecgh/go-spew/spew"
2827
v1 "k8s.io/api/core/v1"
2928
discovery "k8s.io/api/discovery/v1"
3029
"k8s.io/apimachinery/pkg/conversion"
3130
"k8s.io/apimachinery/pkg/labels"
31+
"k8s.io/apimachinery/pkg/util/dump"
3232
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
3333
"k8s.io/apimachinery/pkg/util/sets"
3434
v1listers "k8s.io/client-go/listers/core/v1"
@@ -303,13 +303,7 @@ func stringPtrChanged(ptr1, ptr2 *string) bool {
303303
// copied from k8s.io/kubernetes/pkg/util/hash
304304
func deepHashObject(hasher hash.Hash, objectToWrite interface{}) {
305305
hasher.Reset()
306-
printer := spew.ConfigState{
307-
Indent: " ",
308-
SortKeys: true,
309-
DisableMethods: true,
310-
SpewKeys: true,
311-
}
312-
printer.Fprintf(hasher, "%#v", objectToWrite)
306+
fmt.Fprint(hasher, dump.ForHash(objectToWrite))
313307
}
314308

315309
// IsPodReady returns true if Pods Ready condition is true

0 commit comments

Comments
 (0)