mirror of https://github.com/k3s-io/k3s
commit
16e1de6db6
|
@ -84,9 +84,12 @@ func main() {
|
|||
|
||||
data := new(bytes.Buffer)
|
||||
|
||||
gv := unversioned.ParseGroupVersionOrDie(*groupVersion)
|
||||
gv, err := unversioned.ParseGroupVersion(*groupVersion)
|
||||
if err != nil {
|
||||
glog.Fatalf("Error parsing groupversion %v: %v", *groupVersion, err)
|
||||
}
|
||||
|
||||
_, err := data.WriteString(fmt.Sprintf("package %v\n", gv.Version))
|
||||
_, err = data.WriteString(fmt.Sprintf("package %v\n", gv.Version))
|
||||
if err != nil {
|
||||
glog.Fatalf("Error while writing package line: %v", err)
|
||||
}
|
||||
|
|
|
@ -94,7 +94,10 @@ func main() {
|
|||
|
||||
data := new(bytes.Buffer)
|
||||
|
||||
gv := unversioned.ParseGroupVersionOrDie(*groupVersion)
|
||||
gv, err := unversioned.ParseGroupVersion(*groupVersion)
|
||||
if err != nil {
|
||||
glog.Fatalf("Error parsing groupversion %v: %v", *groupVersion, err)
|
||||
}
|
||||
|
||||
registerTo := destScheme(gv)
|
||||
var pkgname string
|
||||
|
@ -108,7 +111,7 @@ func main() {
|
|||
pkgname = gv.Version
|
||||
}
|
||||
|
||||
_, err := data.WriteString(fmt.Sprintf("package %s\n", pkgname))
|
||||
_, err = data.WriteString(fmt.Sprintf("package %s\n", pkgname))
|
||||
if err != nil {
|
||||
glog.Fatalf("Error while writing package line: %v", err)
|
||||
}
|
||||
|
|
|
@ -33,7 +33,7 @@ import (
|
|||
func TestDeepCopyApiObjects(t *testing.T) {
|
||||
for i := 0; i < *fuzzIters; i++ {
|
||||
for _, version := range []unversioned.GroupVersion{testapi.Default.InternalGroupVersion(), *testapi.Default.GroupVersion()} {
|
||||
f := apitesting.FuzzerFor(t, version.String(), rand.NewSource(rand.Int63()))
|
||||
f := apitesting.FuzzerFor(t, version, rand.NewSource(rand.Int63()))
|
||||
for kind := range api.Scheme.KnownTypes(version) {
|
||||
doDeepCopyTest(t, version.WithKind(kind), f)
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ func doDeepCopyTest(t *testing.T, kind unversioned.GroupVersionKind, f *fuzz.Fuz
|
|||
func TestDeepCopySingleType(t *testing.T) {
|
||||
for i := 0; i < *fuzzIters; i++ {
|
||||
for _, version := range []unversioned.GroupVersion{testapi.Default.InternalGroupVersion(), *testapi.Default.GroupVersion()} {
|
||||
f := apitesting.FuzzerFor(t, version.String(), rand.NewSource(rand.Int63()))
|
||||
f := apitesting.FuzzerFor(t, version, rand.NewSource(rand.Int63()))
|
||||
doDeepCopyTest(t, version.WithKind("Pod"), f)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -41,13 +41,13 @@ import (
|
|||
|
||||
var fuzzIters = flag.Int("fuzz-iters", 20, "How many fuzzing iterations to do.")
|
||||
|
||||
var codecsToTest = []func(version string, item runtime.Object) (runtime.Codec, error){
|
||||
func(version string, item runtime.Object) (runtime.Codec, error) {
|
||||
var codecsToTest = []func(version unversioned.GroupVersion, item runtime.Object) (runtime.Codec, error){
|
||||
func(version unversioned.GroupVersion, item runtime.Object) (runtime.Codec, error) {
|
||||
return testapi.GetCodecForObject(item)
|
||||
},
|
||||
}
|
||||
|
||||
func fuzzInternalObject(t *testing.T, forVersion string, item runtime.Object, seed int64) runtime.Object {
|
||||
func fuzzInternalObject(t *testing.T, forVersion unversioned.GroupVersion, item runtime.Object, seed int64) runtime.Object {
|
||||
apitesting.FuzzerFor(t, forVersion, rand.NewSource(seed)).Fuzz(item)
|
||||
|
||||
j, err := meta.TypeAccessor(item)
|
||||
|
@ -99,9 +99,9 @@ func roundTrip(t *testing.T, codec runtime.Codec, item runtime.Object) {
|
|||
func roundTripSame(t *testing.T, item runtime.Object, except ...string) {
|
||||
set := sets.NewString(except...)
|
||||
seed := rand.Int63()
|
||||
fuzzInternalObject(t, testapi.Default.InternalGroupVersion().String(), item, seed)
|
||||
fuzzInternalObject(t, testapi.Default.InternalGroupVersion(), item, seed)
|
||||
|
||||
version := testapi.Default.GroupVersion().String()
|
||||
version := *testapi.Default.GroupVersion()
|
||||
codecs := []runtime.Codec{}
|
||||
for _, fn := range codecsToTest {
|
||||
codec, err := fn(version, item)
|
||||
|
@ -112,7 +112,7 @@ func roundTripSame(t *testing.T, item runtime.Object, except ...string) {
|
|||
codecs = append(codecs, codec)
|
||||
}
|
||||
|
||||
if !set.Has(version) {
|
||||
if !set.Has(version.String()) {
|
||||
fuzzInternalObject(t, version, item, seed)
|
||||
for _, codec := range codecs {
|
||||
roundTrip(t, codec, item)
|
||||
|
@ -183,7 +183,7 @@ func doRoundTripTest(kind string, t *testing.T) {
|
|||
roundTripSame(t, item, nonRoundTrippableTypesByVersion[kind]...)
|
||||
}
|
||||
if !nonInternalRoundTrippableTypes.Has(kind) {
|
||||
roundTrip(t, api.Codec, fuzzInternalObject(t, testapi.Default.InternalGroupVersion().String(), item, rand.Int63()))
|
||||
roundTrip(t, api.Codec, fuzzInternalObject(t, testapi.Default.InternalGroupVersion(), item, rand.Int63()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -266,7 +266,7 @@ func TestUnversionedTypes(t *testing.T) {
|
|||
const benchmarkSeed = 100
|
||||
|
||||
func benchmarkItems() []v1.Pod {
|
||||
apiObjectFuzzer := apitesting.FuzzerFor(nil, "", rand.NewSource(benchmarkSeed))
|
||||
apiObjectFuzzer := apitesting.FuzzerFor(nil, api.SchemeGroupVersion, rand.NewSource(benchmarkSeed))
|
||||
items := make([]v1.Pod, 2)
|
||||
for i := range items {
|
||||
apiObjectFuzzer.Fuzz(&items[i])
|
||||
|
|
|
@ -50,7 +50,10 @@ func init() {
|
|||
if kubeTestAPI != "" {
|
||||
testGroupVersions := strings.Split(kubeTestAPI, ",")
|
||||
for _, gvString := range testGroupVersions {
|
||||
groupVersion := unversioned.ParseGroupVersionOrDie(gvString)
|
||||
groupVersion, err := unversioned.ParseGroupVersion(gvString)
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("Error parsing groupversion %v: %v", gvString, err))
|
||||
}
|
||||
|
||||
Groups[groupVersion.Group] = TestGroup{
|
||||
externalGroupVersion: groupVersion,
|
||||
|
|
|
@ -39,7 +39,7 @@ import (
|
|||
)
|
||||
|
||||
// FuzzerFor can randomly populate api objects that are destined for version.
|
||||
func FuzzerFor(t *testing.T, version string, src rand.Source) *fuzz.Fuzzer {
|
||||
func FuzzerFor(t *testing.T, version unversioned.GroupVersion, src rand.Source) *fuzz.Fuzzer {
|
||||
f := fuzz.New().NilChance(.5).NumElements(1, 1)
|
||||
if src != nil {
|
||||
f.RandSource(src)
|
||||
|
|
|
@ -162,15 +162,6 @@ func ParseGroupVersion(gv string) (GroupVersion, error) {
|
|||
}
|
||||
}
|
||||
|
||||
func ParseGroupVersionOrDie(gv string) GroupVersion {
|
||||
ret, err := ParseGroupVersion(gv)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
// WithKind creates a GroupVersionKind based on the method receiver's GroupVersion and the passed Kind.
|
||||
func (gv GroupVersion) WithKind(kind string) GroupVersionKind {
|
||||
return GroupVersionKind{Group: gv.Group, Version: gv.Version, Kind: kind}
|
||||
|
|
|
@ -67,7 +67,7 @@ func TestValidateOk(t *testing.T) {
|
|||
}
|
||||
|
||||
seed := rand.Int63()
|
||||
apiObjectFuzzer := apitesting.FuzzerFor(nil, "", rand.NewSource(seed))
|
||||
apiObjectFuzzer := apitesting.FuzzerFor(nil, testapi.Default.InternalGroupVersion(), rand.NewSource(seed))
|
||||
for i := 0; i < 5; i++ {
|
||||
for _, test := range tests {
|
||||
testObj := test.obj
|
||||
|
|
|
@ -42,7 +42,7 @@ func createDNSPod(namespace, wheezyProbeCmd, jessieProbeCmd string) *api.Pod {
|
|||
pod := &api.Pod{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.Version,
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "dns-test-" + string(util.NewUUID()),
|
||||
|
|
|
@ -313,7 +313,7 @@ func testPodWithVolume(image, path string, source *api.EmptyDirVolumeSource) *ap
|
|||
return &api.Pod{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.Version,
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: podName,
|
||||
|
|
|
@ -111,7 +111,7 @@ func testPodWithHostVol(path string, source *api.HostPathVolumeSource) *api.Pod
|
|||
return &api.Pod{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.Version,
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: podName,
|
||||
|
|
|
@ -143,7 +143,7 @@ func (config *KubeletManagedHostConfig) createPodSpec(podName string) *api.Pod {
|
|||
pod := &api.Pod{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.Version,
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: podName,
|
||||
|
@ -204,7 +204,7 @@ func (config *KubeletManagedHostConfig) createPodSpecWithHostNetwork(podName str
|
|||
pod := &api.Pod{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.Version,
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: podName,
|
||||
|
|
|
@ -256,7 +256,7 @@ func (config *KubeProxyTestConfig) createNetShellPodSpec(podName string, node st
|
|||
pod := &api.Pod{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.Version,
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: podName,
|
||||
|
@ -296,7 +296,7 @@ func (config *KubeProxyTestConfig) createTestPodSpec() *api.Pod {
|
|||
pod := &api.Pod{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.Version,
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: testPodName,
|
||||
|
|
|
@ -413,7 +413,7 @@ func testPDPod(diskNames []string, targetHost string, readOnly bool, numContaine
|
|||
pod := &api.Pod{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.Version,
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: "pd-test-" + string(util.NewUUID()),
|
||||
|
|
|
@ -102,7 +102,7 @@ func (config *PrivilegedPodTestConfig) createPrivilegedPodSpec() *api.Pod {
|
|||
pod := &api.Pod{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.Version,
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: privilegedPodName,
|
||||
|
|
|
@ -188,7 +188,7 @@ func rcByNameContainer(name string, replicas int, image string, labels map[strin
|
|||
return &api.ReplicationController{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "ReplicationController",
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.Version,
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
|
|
|
@ -2149,7 +2149,7 @@ func NewHostExecPodSpec(ns, name string) *api.Pod {
|
|||
pod := &api.Pod{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.Version,
|
||||
APIVersion: latest.GroupOrDie(api.GroupName).GroupVersion.String(),
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
|
|
Loading…
Reference in New Issue