From 8de53ce96cb58d56fd00e91d8bcf7761ab498b83 Mon Sep 17 00:00:00 2001 From: Andrea Tosatto Date: Fri, 22 Jan 2021 14:57:14 +0100 Subject: [PATCH 1/7] client-go: export NewDebuggingRoundTripper function and DebugLevel `debuggingRoundTripper` is a useful throbleshooting tool to debug of Kubernetes API requests and their timing. Unfortunately, as of today, it can only be used via the `DebugWrappers` function, which automatically adjust the amount of debug information exposed by the roundTripper based on the configured `klog` verbosity. While `DebugWrappers` definitely fits the purpose for clients using `klog`, this is currently hard to be used for controllers using `controller-runtime`, which uses `github.com/go-logr/logr` for logging. In this PR we change the visibility of `newDebuggingRoundTripper` and `debugLevel` in order to be directly accessible from users of the `k8s.io/client-go/transport` package. In particular, the changes proposed in this PR allow users of `controller-runtime` to use the `debuggingRoundTripper` to intercept Kubernetes API requests as follows ```go import ( ctrl "sigs.k8s.io/controller-runtime" ) func init() { ctrl.SetLogger(zap.New()) } func main() { // wrap the http transport used by the Kubernetes client restConfig, err := ctrl.GetConfig() checkError(setupLog, err, "unable to get kubernetes client config") restConfig.Wrap(func(rt http.RoundTripper) http.RoundTripper { return transport.NewDebuggingRoundTripper(rt, transport.DebugJustURL) }) ... } ``` --- .../client-go/transport/round_trippers.go | 53 +++++---- .../transport/round_trippers_test.go | 102 ++++++++++++++++++ 2 files changed, 133 insertions(+), 22 deletions(-) diff --git a/staging/src/k8s.io/client-go/transport/round_trippers.go b/staging/src/k8s.io/client-go/transport/round_trippers.go index 56df8ead12c..def28aee95a 100644 --- a/staging/src/k8s.io/client-go/transport/round_trippers.go +++ b/staging/src/k8s.io/client-go/transport/round_trippers.go @@ -68,13 +68,13 @@ func HTTPWrappersForConfig(config *Config, rt http.RoundTripper) (http.RoundTrip func DebugWrappers(rt http.RoundTripper) http.RoundTripper { switch { case bool(klog.V(9).Enabled()): - rt = newDebuggingRoundTripper(rt, debugCurlCommand, debugURLTiming, debugResponseHeaders) + rt = NewDebuggingRoundTripper(rt, DebugCurlCommand, DebugURLTiming, DebugResponseHeaders) case bool(klog.V(8).Enabled()): - rt = newDebuggingRoundTripper(rt, debugJustURL, debugRequestHeaders, debugResponseStatus, debugResponseHeaders) + rt = NewDebuggingRoundTripper(rt, DebugJustURL, DebugRequestHeaders, DebugResponseStatus, DebugResponseHeaders) case bool(klog.V(7).Enabled()): - rt = newDebuggingRoundTripper(rt, debugJustURL, debugRequestHeaders, debugResponseStatus) + rt = NewDebuggingRoundTripper(rt, DebugJustURL, DebugRequestHeaders, DebugResponseStatus) case bool(klog.V(6).Enabled()): - rt = newDebuggingRoundTripper(rt, debugURLTiming) + rt = NewDebuggingRoundTripper(rt, DebugURLTiming) } return rt @@ -353,25 +353,35 @@ func (r *requestInfo) toCurl() string { // through it based on what is configured type debuggingRoundTripper struct { delegatedRoundTripper http.RoundTripper - - levels map[debugLevel]bool + levels map[DebugLevel]bool } -type debugLevel int +// DebugLevel is used to enable debugging of certain +// HTTP requests and responses fields via the debuggingRoundTripper. +type DebugLevel int const ( - debugJustURL debugLevel = iota - debugURLTiming - debugCurlCommand - debugRequestHeaders - debugResponseStatus - debugResponseHeaders + // DebugJustURL will add to the debug output HTTP requests method and url. + DebugJustURL DebugLevel = iota + // DebugURLTiming will add to the debug output the duration of HTTP requests. + DebugURLTiming + // DebugCurlCommand will add to the debug output the curl command equivalent to the + // HTTP request. + DebugCurlCommand + // DebugRequestHeaders will add to the debug output the HTTP requests headers. + DebugRequestHeaders + // DebugResponseStatus will add to the debug output the HTTP response status. + DebugResponseStatus + // DebugResponseHeaders will add to the debug output the HTTP response headers. + DebugResponseHeaders ) -func newDebuggingRoundTripper(rt http.RoundTripper, levels ...debugLevel) *debuggingRoundTripper { +// NewDebuggingRoundTripper allows to display in the logs output debug information +// on the API requests performed by the client. +func NewDebuggingRoundTripper(rt http.RoundTripper, levels ...DebugLevel) *debuggingRoundTripper { drt := &debuggingRoundTripper{ delegatedRoundTripper: rt, - levels: make(map[debugLevel]bool, len(levels)), + levels: make(map[DebugLevel]bool, len(levels)), } for _, v := range levels { drt.levels[v] = true @@ -418,14 +428,13 @@ func maskValue(key string, value string) string { func (rt *debuggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, error) { reqInfo := newRequestInfo(req) - if rt.levels[debugJustURL] { + if rt.levels[DebugJustURL] { klog.Infof("%s %s", reqInfo.RequestVerb, reqInfo.RequestURL) } - if rt.levels[debugCurlCommand] { + if rt.levels[DebugCurlCommand] { klog.Infof("%s", reqInfo.toCurl()) - } - if rt.levels[debugRequestHeaders] { + if rt.levels[DebugRequestHeaders] { klog.Info("Request Headers:") for key, values := range reqInfo.RequestHeaders { for _, value := range values { @@ -441,13 +450,13 @@ func (rt *debuggingRoundTripper) RoundTrip(req *http.Request) (*http.Response, e reqInfo.complete(response, err) - if rt.levels[debugURLTiming] { + if rt.levels[DebugURLTiming] { klog.Infof("%s %s %s in %d milliseconds", reqInfo.RequestVerb, reqInfo.RequestURL, reqInfo.ResponseStatus, reqInfo.Duration.Nanoseconds()/int64(time.Millisecond)) } - if rt.levels[debugResponseStatus] { + if rt.levels[DebugResponseStatus] { klog.Infof("Response Status: %s in %d milliseconds", reqInfo.ResponseStatus, reqInfo.Duration.Nanoseconds()/int64(time.Millisecond)) } - if rt.levels[debugResponseHeaders] { + if rt.levels[DebugResponseHeaders] { klog.Info("Response Headers:") for key, values := range reqInfo.ResponseHeaders { for _, value := range values { diff --git a/staging/src/k8s.io/client-go/transport/round_trippers_test.go b/staging/src/k8s.io/client-go/transport/round_trippers_test.go index ac8de24084d..94d4630f5af 100644 --- a/staging/src/k8s.io/client-go/transport/round_trippers_test.go +++ b/staging/src/k8s.io/client-go/transport/round_trippers_test.go @@ -17,6 +17,9 @@ limitations under the License. package transport import ( + "bytes" + "fmt" + "k8s.io/klog/v2" "net/http" "net/url" "reflect" @@ -412,3 +415,102 @@ func TestHeaderEscapeRoundTrip(t *testing.T) { }) } } + +func TestDebuggingRoundTripper(t *testing.T) { + t.Parallel() + + rawUrl := "https://127.0.0.1:12345/api/v1/pods?limit=500" + req := &http.Request{ + Method: http.MethodGet, + Header: map[string][]string{ + "Authorization": []string{"bearer secretauthtoken"}, + "X-Test-Request": []string{"test"}, + }, + } + res := &http.Response{ + Status: "OK", + StatusCode: http.StatusOK, + Header: map[string][]string{ + "X-Test-Response": []string{"test"}, + }, + } + tcs := []struct { + levels []DebugLevel + expectedOutputLines []string + }{ + { + levels: []DebugLevel{DebugJustURL}, + expectedOutputLines: []string{fmt.Sprintf("%s %s", req.Method, rawUrl)}, + }, + { + levels: []DebugLevel{DebugRequestHeaders}, + expectedOutputLines: func() []string { + lines := []string{fmt.Sprintf("Request Headers:\n")} + for key, values := range req.Header { + for _, value := range values { + if key == "Authorization" { + value = "bearer " + } + lines = append(lines, fmt.Sprintf(" %s: %s\n", key, value)) + } + } + return lines + }(), + }, + { + levels: []DebugLevel{DebugResponseHeaders}, + expectedOutputLines: func() []string { + lines := []string{fmt.Sprintf("Response Headers:\n")} + for key, values := range res.Header { + for _, value := range values { + lines = append(lines, fmt.Sprintf(" %s: %s\n", key, value)) + } + } + return lines + }(), + }, + { + levels: []DebugLevel{DebugURLTiming}, + expectedOutputLines: []string{fmt.Sprintf("%s %s %s", req.Method, rawUrl, res.Status)}, + }, + { + levels: []DebugLevel{DebugResponseStatus}, + expectedOutputLines: []string{fmt.Sprintf("Response Status: %s", res.Status)}, + }, + { + levels: []DebugLevel{DebugCurlCommand}, + expectedOutputLines: []string{fmt.Sprintf("curl -k -v -X")}, + }, + } + + for _, tc := range tcs { + // hijack the klog output + tmpWriteBuffer := bytes.NewBuffer(nil) + klog.SetOutput(tmpWriteBuffer) + klog.LogToStderr(false) + + // parse rawUrl + parsedUrl, err := url.Parse(rawUrl) + if err != nil { + t.Fatalf("url.Parse(%q) returned error: %v", rawUrl, err) + } + req.URL = parsedUrl + + // execute the round tripper + rt := &testRoundTripper{ + Response: res, + } + NewDebuggingRoundTripper(rt, tc.levels...).RoundTrip(req) + + // call Flush to ensure the text isn't still buffered + klog.Flush() + + // check if klog's output contains the expected lines + actual := tmpWriteBuffer.String() + for _, expected := range tc.expectedOutputLines { + if !strings.Contains(actual, expected) { + t.Errorf("%q does not contain expected output %q", actual, expected) + } + } + } +} From 9cb5580ac6584cc787a2b2061c6c61656d065392 Mon Sep 17 00:00:00 2001 From: Andrea Tosatto Date: Tue, 26 Jan 2021 22:04:52 +0000 Subject: [PATCH 2/7] Run gofmt against staging/src/k8s.io/client-go/transport/round_trippers.go --- staging/src/k8s.io/client-go/transport/round_trippers.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/staging/src/k8s.io/client-go/transport/round_trippers.go b/staging/src/k8s.io/client-go/transport/round_trippers.go index def28aee95a..25e26f6003f 100644 --- a/staging/src/k8s.io/client-go/transport/round_trippers.go +++ b/staging/src/k8s.io/client-go/transport/round_trippers.go @@ -353,7 +353,7 @@ func (r *requestInfo) toCurl() string { // through it based on what is configured type debuggingRoundTripper struct { delegatedRoundTripper http.RoundTripper - levels map[DebugLevel]bool + levels map[DebugLevel]bool } // DebugLevel is used to enable debugging of certain @@ -381,7 +381,7 @@ const ( func NewDebuggingRoundTripper(rt http.RoundTripper, levels ...DebugLevel) *debuggingRoundTripper { drt := &debuggingRoundTripper{ delegatedRoundTripper: rt, - levels: make(map[DebugLevel]bool, len(levels)), + levels: make(map[DebugLevel]bool, len(levels)), } for _, v := range levels { drt.levels[v] = true From e87349f3caa810b96ed86fac7aec6bd0e73dacb1 Mon Sep 17 00:00:00 2001 From: Andrea Tosatto Date: Tue, 26 Jan 2021 23:14:56 +0000 Subject: [PATCH 3/7] Run gofmt against staging/src/k8s.io/client-go/transport/round_trippers_test.go --- .../client-go/transport/round_trippers_test.go | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/staging/src/k8s.io/client-go/transport/round_trippers_test.go b/staging/src/k8s.io/client-go/transport/round_trippers_test.go index 94d4630f5af..c55ac0f8f14 100644 --- a/staging/src/k8s.io/client-go/transport/round_trippers_test.go +++ b/staging/src/k8s.io/client-go/transport/round_trippers_test.go @@ -421,15 +421,15 @@ func TestDebuggingRoundTripper(t *testing.T) { rawUrl := "https://127.0.0.1:12345/api/v1/pods?limit=500" req := &http.Request{ - Method: http.MethodGet, + Method: http.MethodGet, Header: map[string][]string{ - "Authorization": []string{"bearer secretauthtoken"}, + "Authorization": []string{"bearer secretauthtoken"}, "X-Test-Request": []string{"test"}, }, } res := &http.Response{ - Status: "OK", - StatusCode: http.StatusOK, + Status: "OK", + StatusCode: http.StatusOK, Header: map[string][]string{ "X-Test-Response": []string{"test"}, }, @@ -439,7 +439,7 @@ func TestDebuggingRoundTripper(t *testing.T) { expectedOutputLines []string }{ { - levels: []DebugLevel{DebugJustURL}, + levels: []DebugLevel{DebugJustURL}, expectedOutputLines: []string{fmt.Sprintf("%s %s", req.Method, rawUrl)}, }, { @@ -470,15 +470,15 @@ func TestDebuggingRoundTripper(t *testing.T) { }(), }, { - levels: []DebugLevel{DebugURLTiming}, + levels: []DebugLevel{DebugURLTiming}, expectedOutputLines: []string{fmt.Sprintf("%s %s %s", req.Method, rawUrl, res.Status)}, }, { - levels: []DebugLevel{DebugResponseStatus}, + levels: []DebugLevel{DebugResponseStatus}, expectedOutputLines: []string{fmt.Sprintf("Response Status: %s", res.Status)}, }, { - levels: []DebugLevel{DebugCurlCommand}, + levels: []DebugLevel{DebugCurlCommand}, expectedOutputLines: []string{fmt.Sprintf("curl -k -v -X")}, }, } From 675cefa1d15cadc5d1772d0ced16a3e843488347 Mon Sep 17 00:00:00 2001 From: Andrea Tosatto Date: Tue, 26 Jan 2021 23:29:32 +0000 Subject: [PATCH 4/7] Address golint warnings --- staging/src/k8s.io/client-go/go.mod | 1 + staging/src/k8s.io/client-go/go.sum | 2 ++ .../k8s.io/client-go/transport/round_trippers.go | 2 +- .../client-go/transport/round_trippers_test.go | 14 +++++++------- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/staging/src/k8s.io/client-go/go.mod b/staging/src/k8s.io/client-go/go.mod index ce0f92d94d8..7c9d4c77edc 100644 --- a/staging/src/k8s.io/client-go/go.mod +++ b/staging/src/k8s.io/client-go/go.mod @@ -28,6 +28,7 @@ require ( golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e k8s.io/api v0.0.0 k8s.io/apimachinery v0.0.0 + k8s.io/klog v1.0.0 k8s.io/klog/v2 v2.4.0 k8s.io/utils v0.0.0-20201110183641-67b214c5f920 sigs.k8s.io/yaml v1.2.0 diff --git a/staging/src/k8s.io/client-go/go.sum b/staging/src/k8s.io/client-go/go.sum index 3b41835e9f7..bd5d4aac3da 100644 --- a/staging/src/k8s.io/client-go/go.sum +++ b/staging/src/k8s.io/client-go/go.sum @@ -428,6 +428,8 @@ 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= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= +k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= +k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.4.0 h1:7+X0fUguPyrKEC4WjH8iGDg3laWgMo5tMnRTIGTTxGQ= k8s.io/klog/v2 v2.4.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= diff --git a/staging/src/k8s.io/client-go/transport/round_trippers.go b/staging/src/k8s.io/client-go/transport/round_trippers.go index 25e26f6003f..554ff399fd3 100644 --- a/staging/src/k8s.io/client-go/transport/round_trippers.go +++ b/staging/src/k8s.io/client-go/transport/round_trippers.go @@ -378,7 +378,7 @@ const ( // NewDebuggingRoundTripper allows to display in the logs output debug information // on the API requests performed by the client. -func NewDebuggingRoundTripper(rt http.RoundTripper, levels ...DebugLevel) *debuggingRoundTripper { +func NewDebuggingRoundTripper(rt http.RoundTripper, levels ...DebugLevel) http.RoundTripper { drt := &debuggingRoundTripper{ delegatedRoundTripper: rt, levels: make(map[DebugLevel]bool, len(levels)), diff --git a/staging/src/k8s.io/client-go/transport/round_trippers_test.go b/staging/src/k8s.io/client-go/transport/round_trippers_test.go index c55ac0f8f14..81571226d3e 100644 --- a/staging/src/k8s.io/client-go/transport/round_trippers_test.go +++ b/staging/src/k8s.io/client-go/transport/round_trippers_test.go @@ -419,7 +419,7 @@ func TestHeaderEscapeRoundTrip(t *testing.T) { func TestDebuggingRoundTripper(t *testing.T) { t.Parallel() - rawUrl := "https://127.0.0.1:12345/api/v1/pods?limit=500" + rawURL := "https://127.0.0.1:12345/api/v1/pods?limit=500" req := &http.Request{ Method: http.MethodGet, Header: map[string][]string{ @@ -440,7 +440,7 @@ func TestDebuggingRoundTripper(t *testing.T) { }{ { levels: []DebugLevel{DebugJustURL}, - expectedOutputLines: []string{fmt.Sprintf("%s %s", req.Method, rawUrl)}, + expectedOutputLines: []string{fmt.Sprintf("%s %s", req.Method, rawURL)}, }, { levels: []DebugLevel{DebugRequestHeaders}, @@ -471,7 +471,7 @@ func TestDebuggingRoundTripper(t *testing.T) { }, { levels: []DebugLevel{DebugURLTiming}, - expectedOutputLines: []string{fmt.Sprintf("%s %s %s", req.Method, rawUrl, res.Status)}, + expectedOutputLines: []string{fmt.Sprintf("%s %s %s", req.Method, rawURL, res.Status)}, }, { levels: []DebugLevel{DebugResponseStatus}, @@ -489,12 +489,12 @@ func TestDebuggingRoundTripper(t *testing.T) { klog.SetOutput(tmpWriteBuffer) klog.LogToStderr(false) - // parse rawUrl - parsedUrl, err := url.Parse(rawUrl) + // parse rawURL + parsedURL, err := url.Parse(rawURL) if err != nil { - t.Fatalf("url.Parse(%q) returned error: %v", rawUrl, err) + t.Fatalf("url.Parse(%q) returned error: %v", rawURL, err) } - req.URL = parsedUrl + req.URL = parsedURL // execute the round tripper rt := &testRoundTripper{ From bdd2da5c7eb98e4f7ce02977793b7268c717d98a Mon Sep 17 00:00:00 2001 From: Andrea Tosatto Date: Tue, 26 Jan 2021 23:31:42 +0000 Subject: [PATCH 5/7] Update bazel BUILD file --- staging/src/k8s.io/client-go/transport/BUILD | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/staging/src/k8s.io/client-go/transport/BUILD b/staging/src/k8s.io/client-go/transport/BUILD index 8eb232f2729..6b61098858d 100644 --- a/staging/src/k8s.io/client-go/transport/BUILD +++ b/staging/src/k8s.io/client-go/transport/BUILD @@ -15,7 +15,10 @@ go_test( "transport_test.go", ], embed = [":go_default_library"], - deps = ["//vendor/golang.org/x/oauth2:go_default_library"], + deps = [ + "//vendor/golang.org/x/oauth2:go_default_library", + "//vendor/k8s.io/klog/v2:go_default_library", + ], ) go_library( From 961fa25dd4468cad40274258c701e5d48fa02c5e Mon Sep 17 00:00:00 2001 From: Andrea Tosatto Date: Tue, 26 Jan 2021 23:49:25 +0000 Subject: [PATCH 6/7] Remove unexpected updates to go.mod and go.sum --- staging/src/k8s.io/client-go/go.mod | 1 - staging/src/k8s.io/client-go/go.sum | 2 -- staging/src/k8s.io/client-go/transport/round_trippers.go | 2 +- staging/src/k8s.io/client-go/transport/round_trippers_test.go | 3 ++- 4 files changed, 3 insertions(+), 5 deletions(-) diff --git a/staging/src/k8s.io/client-go/go.mod b/staging/src/k8s.io/client-go/go.mod index 7c9d4c77edc..ce0f92d94d8 100644 --- a/staging/src/k8s.io/client-go/go.mod +++ b/staging/src/k8s.io/client-go/go.mod @@ -28,7 +28,6 @@ require ( golang.org/x/time v0.0.0-20200630173020-3af7569d3a1e k8s.io/api v0.0.0 k8s.io/apimachinery v0.0.0 - k8s.io/klog v1.0.0 k8s.io/klog/v2 v2.4.0 k8s.io/utils v0.0.0-20201110183641-67b214c5f920 sigs.k8s.io/yaml v1.2.0 diff --git a/staging/src/k8s.io/client-go/go.sum b/staging/src/k8s.io/client-go/go.sum index bd5d4aac3da..3b41835e9f7 100644 --- a/staging/src/k8s.io/client-go/go.sum +++ b/staging/src/k8s.io/client-go/go.sum @@ -428,8 +428,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= k8s.io/gengo v0.0.0-20200413195148-3a45101e95ac/go.mod h1:ezvh/TsK7cY6rbqRK0oQQ8IAqLxYwwyPxAX1Pzy0ii0= -k8s.io/klog v1.0.0 h1:Pt+yjF5aB1xDSVbau4VsWe+dQNzA0qv1LlXdC2dF6Q8= -k8s.io/klog v1.0.0/go.mod h1:4Bi6QPql/J/LkTDqv7R/cd3hPo4k2DG6Ptcz060Ez5I= k8s.io/klog/v2 v2.0.0/go.mod h1:PBfzABfn139FHAV07az/IF9Wp1bkk3vpT2XSJ76fSDE= k8s.io/klog/v2 v2.4.0 h1:7+X0fUguPyrKEC4WjH8iGDg3laWgMo5tMnRTIGTTxGQ= k8s.io/klog/v2 v2.4.0/go.mod h1:Od+F08eJP+W3HUb4pSrPpgp9DGU4GzlpG/TmITuYh/Y= diff --git a/staging/src/k8s.io/client-go/transport/round_trippers.go b/staging/src/k8s.io/client-go/transport/round_trippers.go index 554ff399fd3..785d3b2e3a6 100644 --- a/staging/src/k8s.io/client-go/transport/round_trippers.go +++ b/staging/src/k8s.io/client-go/transport/round_trippers.go @@ -23,8 +23,8 @@ import ( "time" "golang.org/x/oauth2" - "k8s.io/klog/v2" + "k8s.io/klog/v2" utilnet "k8s.io/apimachinery/pkg/util/net" ) diff --git a/staging/src/k8s.io/client-go/transport/round_trippers_test.go b/staging/src/k8s.io/client-go/transport/round_trippers_test.go index 81571226d3e..c41852489cd 100644 --- a/staging/src/k8s.io/client-go/transport/round_trippers_test.go +++ b/staging/src/k8s.io/client-go/transport/round_trippers_test.go @@ -19,12 +19,13 @@ package transport import ( "bytes" "fmt" - "k8s.io/klog/v2" "net/http" "net/url" "reflect" "strings" "testing" + + "k8s.io/klog/v2" ) type testRoundTripper struct { From 1449af17555eb5148d11556ee205c42b83821af0 Mon Sep 17 00:00:00 2001 From: Andrea Tosatto Date: Wed, 27 Jan 2021 00:08:07 +0000 Subject: [PATCH 7/7] Re-run gofmt against staging/src/k8s.io/client-go/transport/ --- staging/src/k8s.io/client-go/transport/round_trippers.go | 2 +- .../src/k8s.io/client-go/transport/round_trippers_test.go | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/staging/src/k8s.io/client-go/transport/round_trippers.go b/staging/src/k8s.io/client-go/transport/round_trippers.go index 785d3b2e3a6..cd0a4455f19 100644 --- a/staging/src/k8s.io/client-go/transport/round_trippers.go +++ b/staging/src/k8s.io/client-go/transport/round_trippers.go @@ -24,8 +24,8 @@ import ( "golang.org/x/oauth2" - "k8s.io/klog/v2" utilnet "k8s.io/apimachinery/pkg/util/net" + "k8s.io/klog/v2" ) // HTTPWrappersForConfig wraps a round tripper with any relevant layered diff --git a/staging/src/k8s.io/client-go/transport/round_trippers_test.go b/staging/src/k8s.io/client-go/transport/round_trippers_test.go index c41852489cd..10f7132cd12 100644 --- a/staging/src/k8s.io/client-go/transport/round_trippers_test.go +++ b/staging/src/k8s.io/client-go/transport/round_trippers_test.go @@ -424,15 +424,15 @@ func TestDebuggingRoundTripper(t *testing.T) { req := &http.Request{ Method: http.MethodGet, Header: map[string][]string{ - "Authorization": []string{"bearer secretauthtoken"}, - "X-Test-Request": []string{"test"}, + "Authorization": {"bearer secretauthtoken"}, + "X-Test-Request": {"test"}, }, } res := &http.Response{ Status: "OK", StatusCode: http.StatusOK, Header: map[string][]string{ - "X-Test-Response": []string{"test"}, + "X-Test-Response": {"test"}, }, } tcs := []struct {