From ef522cc423b3f4500c9b6c99c8ea48610ba8df95 Mon Sep 17 00:00:00 2001 From: Hao Ruan Date: Thu, 13 Apr 2023 09:41:07 +0800 Subject: [PATCH] replace spew methods with dump methods Kubernetes-commit: c4e1b01416ec05e6a520a181d4ce3b4333adb4e4 --- go.mod | 13 +++++++------ go.sum | 7 +------ kubernetes_test/timeout_test.go | 5 ++--- restmapper/discovery_test.go | 4 ++-- tools/watch/informerwatcher_test.go | 4 ++-- tools/watch/retrywatcher_test.go | 8 ++++---- 6 files changed, 18 insertions(+), 23 deletions(-) diff --git a/go.mod b/go.mod index 2c5d5f35..5a6d36ee 100644 --- a/go.mod +++ b/go.mod @@ -5,7 +5,6 @@ module k8s.io/client-go go 1.20 require ( - github.com/davecgh/go-spew v1.1.1 github.com/evanphx/json-patch v4.12.0+incompatible github.com/gogo/protobuf v1.3.2 github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da @@ -18,14 +17,14 @@ require ( github.com/imdario/mergo v0.3.6 github.com/peterbourgon/diskv v2.0.1+incompatible github.com/spf13/pflag v1.0.5 - github.com/stretchr/testify v1.8.2 + github.com/stretchr/testify v1.8.1 golang.org/x/net v0.8.0 golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b golang.org/x/term v0.6.0 golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 google.golang.org/protobuf v1.28.1 - k8s.io/api v0.0.0-20230413214513-e2bb673563f3 - k8s.io/apimachinery v0.0.0-20230413213732-71d667e55043 + k8s.io/api v0.0.0 + k8s.io/apimachinery v0.0.0 k8s.io/klog/v2 v2.90.1 k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a k8s.io/utils v0.0.0-20230209194617-a36077c30491 @@ -35,6 +34,7 @@ require ( ) require ( + github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.9.0 // indirect github.com/go-logr/logr v1.2.3 // indirect github.com/go-openapi/jsonpointer v0.19.6 // indirect @@ -59,6 +59,7 @@ require ( ) replace ( - k8s.io/api => k8s.io/api v0.0.0-20230413214513-e2bb673563f3 - k8s.io/apimachinery => k8s.io/apimachinery v0.0.0-20230413213732-71d667e55043 + k8s.io/api => ../api + k8s.io/apimachinery => ../apimachinery + k8s.io/client-go => ../client-go ) diff --git a/go.sum b/go.sum index f23f71ed..58581a9e 100644 --- a/go.sum +++ b/go.sum @@ -189,9 +189,8 @@ github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81P github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= +github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2 h1:+h33VjcLVPDHtOdpUCuF+7gSuG3yGIftsP1YvFihtJ8= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -478,10 +477,6 @@ honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWh honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.0.0-20230413214513-e2bb673563f3 h1:7cfkxfIlr7ggIqRXLQJI9AGPlw4MpZoMvvOrxfWozA8= -k8s.io/api v0.0.0-20230413214513-e2bb673563f3/go.mod h1:66bUJJkYkHsgTaCJvmLcO3K1js02rhyJxO2Ghgb4u3U= -k8s.io/apimachinery v0.0.0-20230413213732-71d667e55043 h1:z1mXDRFnQs+G2UBA4Z7+orSi6YR1gx0vpqyfMhT+uUs= -k8s.io/apimachinery v0.0.0-20230413213732-71d667e55043/go.mod h1:GBAjO2cow0Oymo5PgZq/mZf1haAb11cT37eQBWNSWXg= k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= k8s.io/kube-openapi v0.0.0-20230308215209-15aac26d736a h1:gmovKNur38vgoWfGtP5QOGNOA7ki4n6qNYoFAgMlNvg= diff --git a/kubernetes_test/timeout_test.go b/kubernetes_test/timeout_test.go index ce3d8134..84fde895 100644 --- a/kubernetes_test/timeout_test.go +++ b/kubernetes_test/timeout_test.go @@ -23,10 +23,9 @@ import ( "net/http" "testing" - "github.com/davecgh/go-spew/spew" - appsv1 "k8s.io/api/apps/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/util/dump" "k8s.io/client-go/kubernetes" "k8s.io/client-go/kubernetes/scheme" "k8s.io/client-go/rest" @@ -39,7 +38,7 @@ func TestListTimeout(t *testing.T) { NegotiatedSerializer: scheme.Codecs, Client: manualfake.CreateHTTPClient(func(req *http.Request) (*http.Response, error) { if req.URL.Query().Get("timeout") != "21s" { - t.Fatal(spew.Sdump(req.URL.Query())) + t.Fatal(dump.Pretty(req.URL.Query())) } return &http.Response{StatusCode: http.StatusNotFound, Body: io.NopCloser(&bytes.Buffer{})}, nil }), diff --git a/restmapper/discovery_test.go b/restmapper/discovery_test.go index 045b3d79..f0cfba38 100644 --- a/restmapper/discovery_test.go +++ b/restmapper/discovery_test.go @@ -21,10 +21,10 @@ import ( "reflect" "testing" - "github.com/davecgh/go-spew/spew" "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/dump" "k8s.io/apimachinery/pkg/version" . "k8s.io/client-go/discovery" "k8s.io/client-go/openapi" @@ -364,7 +364,7 @@ func TestGetAPIGroupResources(t *testing.T) { t.Fatalf("unexpected error: %v", err) } if !reflect.DeepEqual(test.expected, got) { - t.Errorf("unexpected result:\nexpected = %s\ngot = %s", spew.Sdump(test.expected), spew.Sdump(got)) + t.Errorf("unexpected result:\nexpected = %s\ngot = %s", dump.Pretty(test.expected), dump.Pretty(got)) } }) } diff --git a/tools/watch/informerwatcher_test.go b/tools/watch/informerwatcher_test.go index 138502c8..5ff2f22e 100644 --- a/tools/watch/informerwatcher_test.go +++ b/tools/watch/informerwatcher_test.go @@ -24,7 +24,6 @@ import ( "testing" "time" - "github.com/davecgh/go-spew/spew" "github.com/google/go-cmp/cmp" corev1 "k8s.io/api/core/v1" @@ -32,6 +31,7 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/dump" "k8s.io/apimachinery/pkg/watch" fakeclientset "k8s.io/client-go/kubernetes/fake" testcore "k8s.io/client-go/testing" @@ -260,7 +260,7 @@ func TestNewInformerWatcher(t *testing.T) { sort.Sort(byEventTypeAndName(result)) if !reflect.DeepEqual(expected, result) { - t.Error(spew.Errorf("\nexpected: %#v,\ngot: %#v,\ndiff: %s", expected, result, cmp.Diff(expected, result))) + t.Errorf("\nexpected: %s,\ngot: %s,\ndiff: %s", dump.Pretty(expected), dump.Pretty(result), cmp.Diff(expected, result)) return } diff --git a/tools/watch/retrywatcher_test.go b/tools/watch/retrywatcher_test.go index 3871d98b..fff3a46c 100644 --- a/tools/watch/retrywatcher_test.go +++ b/tools/watch/retrywatcher_test.go @@ -26,13 +26,13 @@ import ( "testing" "time" - "github.com/davecgh/go-spew/spew" "github.com/google/go-cmp/cmp" apierrors "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/runtime/schema" + "k8s.io/apimachinery/pkg/util/dump" "k8s.io/apimachinery/pkg/util/wait" "k8s.io/apimachinery/pkg/watch" "k8s.io/client-go/tools/cache" @@ -530,7 +530,7 @@ func TestRetryWatcher(t *testing.T) { for i := 0; i < len(tc.expected); i++ { event, ok := <-watcher.ResultChan() if !ok { - t.Error(spew.Errorf("expected event %#+v, but channel is closed"), tc.expected[i]) + t.Errorf("expected event %s, but channel is closed", dump.Pretty(tc.expected[i])) break } @@ -544,7 +544,7 @@ func TestRetryWatcher(t *testing.T) { select { case event, ok := <-watcher.ResultChan(): if ok { - t.Error(spew.Errorf("Unexpected event received after reading all the expected ones: %#+v", event)) + t.Errorf("Unexpected event received after reading all the expected ones: %s", dump.Pretty(event)) } case <-time.After(10 * time.Millisecond): break @@ -564,7 +564,7 @@ func TestRetryWatcher(t *testing.T) { } if !reflect.DeepEqual(tc.expected, got) { - t.Fatal(spew.Errorf("expected %#+v, got %#+v;\ndiff: %s", tc.expected, got, cmp.Diff(tc.expected, got))) + t.Fatalf("expected %s, got %s;\ndiff: %s", dump.Pretty(tc.expected), dump.Pretty(got), cmp.Diff(tc.expected, got)) } }) }