From f6b3c5fb3f78d1d2736fe97326b976783b34f6b7 Mon Sep 17 00:00:00 2001 From: Sai Harsha Kottapalli Date: Wed, 30 Sep 2020 15:33:29 +0530 Subject: [PATCH] fix staticcheck for kubectl pkg files --- hack/.staticcheck_failures | 2 -- staging/src/k8s.io/kubectl/pkg/cmd/get/customcolumn.go | 4 ++-- staging/src/k8s.io/kubectl/pkg/cmd/get/get_test.go | 2 +- staging/src/k8s.io/kubectl/pkg/cmd/testing/fake.go | 3 --- 4 files changed, 3 insertions(+), 8 deletions(-) diff --git a/hack/.staticcheck_failures b/hack/.staticcheck_failures index c85de44fc73..f38289d66b9 100644 --- a/hack/.staticcheck_failures +++ b/hack/.staticcheck_failures @@ -58,7 +58,5 @@ vendor/k8s.io/client-go/rest/watch vendor/k8s.io/client-go/restmapper vendor/k8s.io/client-go/tools/leaderelection vendor/k8s.io/client-go/transport -vendor/k8s.io/kubectl/pkg/cmd/get vendor/k8s.io/kubectl/pkg/cmd/scale -vendor/k8s.io/kubectl/pkg/cmd/testing vendor/k8s.io/metrics/pkg/client/custom_metrics diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/get/customcolumn.go b/staging/src/k8s.io/kubectl/pkg/cmd/get/customcolumn.go index af99c3f64e4..f9f481769b1 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/get/customcolumn.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/get/customcolumn.go @@ -162,8 +162,8 @@ func (s *CustomColumnsPrinter) PrintObj(obj runtime.Object, out io.Writer) error return fmt.Errorf(printers.InternalObjectPrinterErr) } - if w, found := out.(*tabwriter.Writer); !found { - w = printers.GetNewTabWriter(out) + if _, found := out.(*tabwriter.Writer); !found { + w := printers.GetNewTabWriter(out) out = w defer w.Flush() } diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/get/get_test.go b/staging/src/k8s.io/kubectl/pkg/cmd/get/get_test.go index e3025d17e6f..004b292a4cb 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/get/get_test.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/get/get_test.go @@ -55,7 +55,6 @@ import ( ) var ( - openapiSchemaPath = filepath.Join("..", "..", "..", "testdata", "openapi", "swagger.json") grace = int64(30) enableServiceLinks = corev1.DefaultEnableServiceLinks ) @@ -90,6 +89,7 @@ func testComponentStatusData() *corev1.ComponentStatusList { // Verifies that schemas that are not in the master tree of Kubernetes can be retrieved via Get. func TestGetUnknownSchemaObject(t *testing.T) { t.Skip("This test is completely broken. The first thing it does is add the object to the scheme!") + var openapiSchemaPath = filepath.Join("..", "..", "..", "testdata", "openapi", "swagger.json") tf := cmdtesting.NewTestFactory().WithNamespace("test") defer tf.Cleanup() _, _, codec := cmdtesting.NewExternalScheme() diff --git a/staging/src/k8s.io/kubectl/pkg/cmd/testing/fake.go b/staging/src/k8s.io/kubectl/pkg/cmd/testing/fake.go index 3f160e4d379..1264eca62f7 100644 --- a/staging/src/k8s.io/kubectl/pkg/cmd/testing/fake.go +++ b/staging/src/k8s.io/kubectl/pkg/cmd/testing/fake.go @@ -18,7 +18,6 @@ package testing import ( "bytes" - "errors" "fmt" "io/ioutil" "os" @@ -271,8 +270,6 @@ func convertExternalNamespacedType2ToInternalNamespacedType(in *ExternalNamespac return nil } -var errInvalidVersion = errors.New("not a version") - // ValidVersion of API var ValidVersion = "v1"