mirror of https://github.com/k3s-io/k3s
remove /k8s.io/kubernetes/pkg/kubectl/testing
parent
8e4084e4d5
commit
071200128f
|
@ -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
|
||||
|
|
|
@ -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",
|
||||
],
|
||||
|
|
|
@ -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"],
|
||||
)
|
|
@ -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
|
|
@ -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"`
|
||||
}
|
|
@ -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
|
||||
}
|
||||
}
|
|
@ -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",
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue