diff --git a/hack/.golint_failures b/hack/.golint_failures index 659d1c2549..1d88b07b7f 100644 --- a/hack/.golint_failures +++ b/hack/.golint_failures @@ -154,7 +154,6 @@ pkg/kubectl/cmd/util/jsonmerge pkg/kubectl/cmd/util/sanity pkg/kubectl/metricsutil pkg/kubectl/resource -pkg/kubectl/testing pkg/kubectl/util pkg/kubectl/util/crlf pkg/kubectl/util/slice diff --git a/pkg/kubectl/BUILD b/pkg/kubectl/BUILD index ecfbc750b1..a67266440b 100644 --- a/pkg/kubectl/BUILD +++ b/pkg/kubectl/BUILD @@ -219,7 +219,6 @@ filegroup( "//pkg/kubectl/proxy:all-srcs", "//pkg/kubectl/resource:all-srcs", "//pkg/kubectl/scheme:all-srcs", - "//pkg/kubectl/testing:all-srcs", "//pkg/kubectl/util:all-srcs", "//pkg/kubectl/validation:all-srcs", ], diff --git a/pkg/kubectl/testing/BUILD b/pkg/kubectl/testing/BUILD deleted file mode 100644 index f6fff93f03..0000000000 --- a/pkg/kubectl/testing/BUILD +++ /dev/null @@ -1,30 +0,0 @@ -load("@io_bazel_rules_go//go:def.bzl", "go_library") - -go_library( - name = "go_default_library", - srcs = [ - "doc.go", - "types.go", - "zz_generated.deepcopy.go", - ], - importpath = "k8s.io/kubernetes/pkg/kubectl/testing", - visibility = ["//visibility:public"], - deps = [ - "//vendor/k8s.io/apimachinery/pkg/apis/meta/v1:go_default_library", - "//vendor/k8s.io/apimachinery/pkg/runtime:go_default_library", - ], -) - -filegroup( - name = "package-srcs", - srcs = glob(["**"]), - tags = ["automanaged"], - visibility = ["//visibility:private"], -) - -filegroup( - name = "all-srcs", - srcs = [":package-srcs"], - tags = ["automanaged"], - visibility = ["//visibility:public"], -) diff --git a/pkg/kubectl/testing/doc.go b/pkg/kubectl/testing/doc.go deleted file mode 100644 index 0ea5066098..0000000000 --- a/pkg/kubectl/testing/doc.go +++ /dev/null @@ -1,19 +0,0 @@ -/* -Copyright 2017 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// +k8s:deepcopy-gen=package - -package testing diff --git a/pkg/kubectl/testing/types.go b/pkg/kubectl/testing/types.go deleted file mode 100644 index 23e417e130..0000000000 --- a/pkg/kubectl/testing/types.go +++ /dev/null @@ -1,33 +0,0 @@ -/* -Copyright 2015 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -package testing - -import ( - metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" -) - -// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object - -type TestStruct struct { - metav1.TypeMeta `json:",inline"` - // +optional - metav1.ObjectMeta `json:"metadata,omitempty"` - Key string `json:"Key"` - Map map[string]int `json:"Map"` - StringList []string `json:"StringList"` - IntList []int `json:"IntList"` -} diff --git a/pkg/kubectl/testing/zz_generated.deepcopy.go b/pkg/kubectl/testing/zz_generated.deepcopy.go deleted file mode 100644 index eb5bbb34af..0000000000 --- a/pkg/kubectl/testing/zz_generated.deepcopy.go +++ /dev/null @@ -1,69 +0,0 @@ -// +build !ignore_autogenerated - -/* -Copyright 2018 The Kubernetes Authors. - -Licensed under the Apache License, Version 2.0 (the "License"); -you may not use this file except in compliance with the License. -You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - -Unless required by applicable law or agreed to in writing, software -distributed under the License is distributed on an "AS IS" BASIS, -WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -See the License for the specific language governing permissions and -limitations under the License. -*/ - -// This file was autogenerated by deepcopy-gen. Do not edit it manually! - -package testing - -import ( - runtime "k8s.io/apimachinery/pkg/runtime" -) - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *TestStruct) DeepCopyInto(out *TestStruct) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - if in.Map != nil { - in, out := &in.Map, &out.Map - *out = make(map[string]int, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.StringList != nil { - in, out := &in.StringList, &out.StringList - *out = make([]string, len(*in)) - copy(*out, *in) - } - if in.IntList != nil { - in, out := &in.IntList, &out.IntList - *out = make([]int, len(*in)) - copy(*out, *in) - } - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new TestStruct. -func (in *TestStruct) DeepCopy() *TestStruct { - if in == nil { - return nil - } - out := new(TestStruct) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *TestStruct) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } else { - return nil - } -} diff --git a/pkg/printers/internalversion/BUILD b/pkg/printers/internalversion/BUILD index eb2e66920a..edbd167520 100644 --- a/pkg/printers/internalversion/BUILD +++ b/pkg/printers/internalversion/BUILD @@ -28,7 +28,6 @@ go_test( "//pkg/apis/storage:go_default_library", "//pkg/client/clientset_generated/internalclientset:go_default_library", "//pkg/client/clientset_generated/internalclientset/fake:go_default_library", - "//pkg/kubectl/testing:go_default_library", "//pkg/printers:go_default_library", "//pkg/util/pointer:go_default_library", "//vendor/github.com/ghodss/yaml:go_default_library", diff --git a/pkg/printers/internalversion/printers_test.go b/pkg/printers/internalversion/printers_test.go index 8662c91fc3..0f2c530f86 100644 --- a/pkg/printers/internalversion/printers_test.go +++ b/pkg/printers/internalversion/printers_test.go @@ -50,30 +50,42 @@ import ( "k8s.io/kubernetes/pkg/apis/extensions" "k8s.io/kubernetes/pkg/apis/policy" "k8s.io/kubernetes/pkg/apis/storage" - kubectltesting "k8s.io/kubernetes/pkg/kubectl/testing" "k8s.io/kubernetes/pkg/printers" ) func init() { - legacyscheme.Scheme.AddKnownTypes(testapi.Default.InternalGroupVersion(), &kubectltesting.TestStruct{}) - legacyscheme.Scheme.AddKnownTypes(legacyscheme.Registry.GroupOrDie(api.GroupName).GroupVersion, &kubectltesting.TestStruct{}) + legacyscheme.Scheme.AddKnownTypes(testapi.Default.InternalGroupVersion(), &TestPrintType{}) + legacyscheme.Scheme.AddKnownTypes(legacyscheme.Registry.GroupOrDie(api.GroupName).GroupVersion, &TestPrintType{}) } -var testData = kubectltesting.TestStruct{ +var testData = TestStruct{ Key: "testValue", Map: map[string]int{"TestSubkey": 1}, StringList: []string{"a", "b", "c"}, IntList: []int{1, 2, 3}, } +type TestStruct struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Key string `json:"Key"` + Map map[string]int `json:"Map"` + StringList []string `json:"StringList"` + IntList []int `json:"IntList"` +} + +func (in *TestStruct) DeepCopyObject() runtime.Object { + panic("never called") +} + func TestVersionedPrinter(t *testing.T) { - original := &kubectltesting.TestStruct{Key: "value"} + original := &TestPrintType{Data: "value"} p := printers.NewVersionedPrinter( printers.ResourcePrinterFunc(func(obj runtime.Object, w io.Writer) error { if obj == original { t.Fatalf("object should not be identical: %#v", obj) } - if obj.(*kubectltesting.TestStruct).Key != "value" { + if obj.(*TestPrintType).Data != "value" { t.Fatalf("object was not converted: %#v", obj) } return nil @@ -315,14 +327,14 @@ func testPrinter(t *testing.T, printer printers.ResourcePrinter, unmarshalFunc f if err != nil { t.Fatal(err) } - var poutput kubectltesting.TestStruct + var poutput TestStruct // Verify that given function runs without error. err = unmarshalFunc(buf.Bytes(), &poutput) if err != nil { t.Fatal(err) } // Use real decode function to undo the versioning process. - poutput = kubectltesting.TestStruct{} + poutput = TestStruct{} s := yamlserializer.NewDecodingSerializer(testapi.Default.Codec()) if err := runtime.DecodeInto(s, buf.Bytes(), &poutput); err != nil { t.Fatal(err)