mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-29 22:46:12 +00:00
Merge pull request #128584 from thockin/compartmentalize_spew
Compartmentalize spew more
This commit is contained in:
commit
b631dae569
@ -54,6 +54,7 @@
|
|||||||
- "./staging/src/k8s.io/code-generator/examples"
|
- "./staging/src/k8s.io/code-generator/examples"
|
||||||
- "./staging/src/k8s.io/code-generator/cmd/defaulter-gen/output_tests"
|
- "./staging/src/k8s.io/code-generator/cmd/defaulter-gen/output_tests"
|
||||||
allowedImports:
|
allowedImports:
|
||||||
|
- k8s.io/apimachinery
|
||||||
- k8s.io/gengo/v2
|
- k8s.io/gengo/v2
|
||||||
- k8s.io/code-generator
|
- k8s.io/code-generator
|
||||||
- k8s.io/kube-openapi
|
- k8s.io/kube-openapi
|
||||||
|
@ -21,9 +21,9 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
fuzz "github.com/google/gofuzz"
|
||||||
"github.com/google/gofuzz"
|
|
||||||
|
|
||||||
|
"k8s.io/apimachinery/pkg/util/dump"
|
||||||
"k8s.io/code-generator/cmd/deepcopy-gen/output_tests/aliases"
|
"k8s.io/code-generator/cmd/deepcopy-gen/output_tests/aliases"
|
||||||
"k8s.io/code-generator/cmd/deepcopy-gen/output_tests/builtins"
|
"k8s.io/code-generator/cmd/deepcopy-gen/output_tests/builtins"
|
||||||
"k8s.io/code-generator/cmd/deepcopy-gen/output_tests/interfaces"
|
"k8s.io/code-generator/cmd/deepcopy-gen/output_tests/interfaces"
|
||||||
@ -60,19 +60,19 @@ func TestWithValueFuzzer(t *testing.T) {
|
|||||||
reflectCopy := ReflectDeepCopy(original)
|
reflectCopy := ReflectDeepCopy(original)
|
||||||
|
|
||||||
if !reflect.DeepEqual(original, reflectCopy) {
|
if !reflect.DeepEqual(original, reflectCopy) {
|
||||||
t.Errorf("original and reflectCopy are different:\n\n original = %s\n\n jsonCopy = %s", spew.Sdump(original), spew.Sdump(reflectCopy))
|
t.Errorf("original and reflectCopy are different:\n\n original = %s\n\n jsonCopy = %s", dump.Pretty(original), dump.Pretty(reflectCopy))
|
||||||
}
|
}
|
||||||
|
|
||||||
deepCopy := reflect.ValueOf(original).MethodByName("DeepCopy").Call(nil)[0].Interface()
|
deepCopy := reflect.ValueOf(original).MethodByName("DeepCopy").Call(nil)[0].Interface()
|
||||||
|
|
||||||
if !reflect.DeepEqual(original, deepCopy) {
|
if !reflect.DeepEqual(original, deepCopy) {
|
||||||
t.Fatalf("original and deepCopy are different:\n\n original = %s\n\n deepCopy() = %s", spew.Sdump(original), spew.Sdump(deepCopy))
|
t.Fatalf("original and deepCopy are different:\n\n original = %s\n\n deepCopy() = %s", dump.Pretty(original), dump.Pretty(deepCopy))
|
||||||
}
|
}
|
||||||
|
|
||||||
ValueFuzz(original)
|
ValueFuzz(original)
|
||||||
|
|
||||||
if !reflect.DeepEqual(reflectCopy, deepCopy) {
|
if !reflect.DeepEqual(reflectCopy, deepCopy) {
|
||||||
t.Fatalf("reflectCopy and deepCopy are different:\n\n origin = %s\n\n jsonCopy() = %s", spew.Sdump(original), spew.Sdump(deepCopy))
|
t.Fatalf("reflectCopy and deepCopy are different:\n\n origin = %s\n\n jsonCopy() = %s", dump.Pretty(original), dump.Pretty(deepCopy))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
@ -7,7 +7,6 @@ go 1.23.0
|
|||||||
godebug default=go1.23
|
godebug default=go1.23
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
|
|
||||||
github.com/gogo/protobuf v1.3.2
|
github.com/gogo/protobuf v1.3.2
|
||||||
github.com/google/gnostic-models v0.6.8
|
github.com/google/gnostic-models v0.6.8
|
||||||
github.com/google/go-cmp v0.6.0
|
github.com/google/go-cmp v0.6.0
|
||||||
@ -22,6 +21,7 @@ require (
|
|||||||
)
|
)
|
||||||
|
|
||||||
require (
|
require (
|
||||||
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
||||||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
||||||
github.com/go-logr/logr v1.4.2 // indirect
|
github.com/go-logr/logr v1.4.2 // indirect
|
||||||
|
@ -7,7 +7,6 @@ go 1.23.0
|
|||||||
godebug default=go1.23
|
godebug default=go1.23
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc
|
|
||||||
github.com/google/go-cmp v0.6.0
|
github.com/google/go-cmp v0.6.0
|
||||||
github.com/stretchr/testify v1.9.0
|
github.com/stretchr/testify v1.9.0
|
||||||
k8s.io/api v0.0.0
|
k8s.io/api v0.0.0
|
||||||
@ -22,6 +21,7 @@ require (
|
|||||||
github.com/beorn7/perks v1.0.1 // indirect
|
github.com/beorn7/perks v1.0.1 // indirect
|
||||||
github.com/blang/semver/v4 v4.0.0 // indirect
|
github.com/blang/semver/v4 v4.0.0 // indirect
|
||||||
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
github.com/cespare/xxhash/v2 v2.3.0 // indirect
|
||||||
|
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
|
||||||
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
github.com/emicklei/go-restful/v3 v3.11.0 // indirect
|
||||||
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
github.com/fxamacker/cbor/v2 v2.7.0 // indirect
|
||||||
github.com/go-logr/logr v1.4.2 // indirect
|
github.com/go-logr/logr v1.4.2 // indirect
|
||||||
|
@ -24,11 +24,11 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"sort"
|
"sort"
|
||||||
|
|
||||||
"github.com/davecgh/go-spew/spew"
|
|
||||||
v1 "k8s.io/api/core/v1"
|
v1 "k8s.io/api/core/v1"
|
||||||
discovery "k8s.io/api/discovery/v1"
|
discovery "k8s.io/api/discovery/v1"
|
||||||
"k8s.io/apimachinery/pkg/conversion"
|
"k8s.io/apimachinery/pkg/conversion"
|
||||||
"k8s.io/apimachinery/pkg/labels"
|
"k8s.io/apimachinery/pkg/labels"
|
||||||
|
"k8s.io/apimachinery/pkg/util/dump"
|
||||||
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
|
||||||
"k8s.io/apimachinery/pkg/util/sets"
|
"k8s.io/apimachinery/pkg/util/sets"
|
||||||
v1listers "k8s.io/client-go/listers/core/v1"
|
v1listers "k8s.io/client-go/listers/core/v1"
|
||||||
@ -303,13 +303,7 @@ func stringPtrChanged(ptr1, ptr2 *string) bool {
|
|||||||
// copied from k8s.io/kubernetes/pkg/util/hash
|
// copied from k8s.io/kubernetes/pkg/util/hash
|
||||||
func deepHashObject(hasher hash.Hash, objectToWrite interface{}) {
|
func deepHashObject(hasher hash.Hash, objectToWrite interface{}) {
|
||||||
hasher.Reset()
|
hasher.Reset()
|
||||||
printer := spew.ConfigState{
|
fmt.Fprint(hasher, dump.ForHash(objectToWrite))
|
||||||
Indent: " ",
|
|
||||||
SortKeys: true,
|
|
||||||
DisableMethods: true,
|
|
||||||
SpewKeys: true,
|
|
||||||
}
|
|
||||||
printer.Fprintf(hasher, "%#v", objectToWrite)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsPodReady returns true if Pods Ready condition is true
|
// IsPodReady returns true if Pods Ready condition is true
|
||||||
|
Loading…
Reference in New Issue
Block a user