Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

miscellaneous group version updates #18859

Merged
merged 1 commit into from
Dec 24, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 5 additions & 2 deletions cmd/genconversion/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
7 changes: 5 additions & 2 deletions cmd/gendeepcopy/deep_copy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
}
Expand Down
4 changes: 2 additions & 2 deletions pkg/api/copy_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
}
Expand Down
16 changes: 8 additions & 8 deletions pkg/api/serialization_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down Expand Up @@ -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()))
}
}

Expand Down Expand Up @@ -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])
Expand Down
5 changes: 4 additions & 1 deletion pkg/api/testapi/testapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/testing/fuzzer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
9 changes: 0 additions & 9 deletions pkg/api/unversioned/group_version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
2 changes: 1 addition & 1 deletion pkg/api/validation/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/dns.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/empty_dir.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/host_path.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/kubelet_etc_hosts.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions test/e2e/kubeproxy.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,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,
Expand Down Expand Up @@ -295,7 +295,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,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/pd.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/privileged.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/resize_nodes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down