From c12a23725d4a271c778863925b670f2ca6644d59 Mon Sep 17 00:00:00 2001 From: Ryan Richard Date: Thu, 11 Mar 2021 16:21:40 -0800 Subject: [PATCH] Fix lint errors from a previous commit --- go.mod | 2 +- .../concierge_impersonation_proxy_test.go | 20 ++++++++++++------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/go.mod b/go.mod index b8f1a732..004c3c08 100644 --- a/go.mod +++ b/go.mod @@ -27,7 +27,7 @@ require ( github.com/spf13/pflag v1.0.5 github.com/stretchr/testify v1.7.0 golang.org/x/crypto v0.0.0-20201217014255-9d1352758620 - golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 // indirect + golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d golang.org/x/sync v0.0.0-20201207232520-09787c993a3a golang.org/x/tools v0.0.0-20200825202427-b303f430e36d // indirect diff --git a/test/integration/concierge_impersonation_proxy_test.go b/test/integration/concierge_impersonation_proxy_test.go index 233d9795..095f8bb0 100644 --- a/test/integration/concierge_impersonation_proxy_test.go +++ b/test/integration/concierge_impersonation_proxy_test.go @@ -566,9 +566,7 @@ func TestImpersonationProxy(t *testing.T) { //nolint:gocyclo // yeah, it's compl conciergePod = &pod } } - if conciergePod == nil { - t.Error("could not find a concierge pod") - } + require.NotNil(t, conciergePod, "could not find a concierge pod") // Try "kubectl exec" through the impersonation proxy. echoString := "hello world" @@ -788,13 +786,17 @@ func TestImpersonationProxy(t *testing.T) { //nolint:gocyclo // yeah, it's compl dest, _ := url.Parse(impersonationProxyURL) dest.Path = "/api/v1/namespaces/" + namespaceName + "/configmaps/configmap-1" - response, err := httpClient.Get(dest.String()) + getConfigmapRequest, err := http.NewRequestWithContext(ctx, http.MethodGet, dest.String(), nil) + require.NoError(t, err) + response, err := httpClient.Do(getConfigmapRequest) require.NoError(t, err) body, _ := ioutil.ReadAll(response.Body) t.Logf("http2 status code: %d, proto: %s, message: %s", response.StatusCode, response.Proto, body) require.Equal(t, "HTTP/2.0", response.Proto) require.Equal(t, http.StatusOK, response.StatusCode) - defer response.Body.Close() + defer func() { + require.NoError(t, response.Body.Close()) + }() var actualConfigMap corev1.ConfigMap require.NoError(t, json.Unmarshal(body, &actualConfigMap)) actualConfigMap.TypeMeta = metav1.TypeMeta{} // This isn't filled out in the wantConfigMap we got back from create. @@ -807,11 +809,15 @@ func TestImpersonationProxy(t *testing.T) { //nolint:gocyclo // yeah, it's compl "labelSelector": {fmt.Sprintf("%s=%s", wantConfigMapLabelKey, wantConfigMapLabelValue)}, "resourceVersion": {"0"}, }.Encode() - response, err = httpClient.Get(dest.String()) + watchConfigmapsRequest, err := http.NewRequestWithContext(ctx, http.MethodGet, dest.String(), nil) + require.NoError(t, err) + response, err = httpClient.Do(watchConfigmapsRequest) require.NoError(t, err) require.Equal(t, "HTTP/2.0", response.Proto) require.Equal(t, http.StatusOK, response.StatusCode) - defer response.Body.Close() + defer func() { + require.NoError(t, response.Body.Close()) + }() // decode decoder := json.NewDecoder(response.Body)