remove Versions from GroupMeta

This commit is contained in:
deads2k
2015-12-02 15:47:42 -05:00
parent 643cb7a1c7
commit 675d8a235e
10 changed files with 17 additions and 43 deletions

View File

@@ -20,7 +20,6 @@ package install
import (
"fmt"
"strings"
"github.com/golang/glog"
@@ -57,13 +56,10 @@ func init() {
Codec: runtime.CodecFor(api.Scheme, groupVersion.String()),
}
var versions []string
worstToBestGroupVersions := []unversioned.GroupVersion{}
for i := len(registeredGroupVersions) - 1; i >= 0; i-- {
versions = append(versions, registeredGroupVersions[i].Version)
worstToBestGroupVersions = append(worstToBestGroupVersions, registeredGroupVersions[i])
}
groupMeta.Versions = versions
groupMeta.GroupVersions = registeredGroupVersions
groupMeta.SelfLinker = runtime.SelfLinker(accessor)
@@ -111,7 +107,7 @@ func interfacesFor(version string) (*meta.VersionInterfaces, error) {
default:
{
g, _ := latest.Group("")
return nil, fmt.Errorf("unsupported storage version: %s (valid: %s)", version, strings.Join(g.Versions, ", "))
return nil, fmt.Errorf("unsupported storage version: %s (valid: %v)", version, g.GroupVersions)
}
}
}

View File

@@ -66,8 +66,8 @@ func TestInterfacesFor(t *testing.T) {
if _, err := latest.GroupOrDie("").InterfacesFor(""); err == nil {
t.Fatalf("unexpected non-error: %v", err)
}
for i, version := range append([]string{latest.GroupOrDie("").GroupVersion.Version}, latest.GroupOrDie("").Versions...) {
if vi, err := latest.GroupOrDie("").InterfacesFor(version); err != nil || vi == nil {
for i, version := range latest.GroupOrDie("").GroupVersions {
if vi, err := latest.GroupOrDie("").InterfacesFor(version.Version); err != nil || vi == nil {
t.Fatalf("%d: unexpected result: %v", i, err)
}
}
@@ -86,10 +86,8 @@ func TestRESTMapper(t *testing.T) {
t.Errorf("unexpected version mapping: %#v %v", m, err)
}
for _, version := range latest.GroupOrDie("").Versions {
currGroupVersion := unversioned.GroupVersion{Version: version}
mapping, err := latest.GroupOrDie("").RESTMapper.RESTMapping(rcGVK.GroupKind(), currGroupVersion.String())
for _, version := range latest.GroupOrDie("").GroupVersions {
mapping, err := latest.GroupOrDie("").RESTMapper.RESTMapping(rcGVK.GroupKind(), version.Version)
if err != nil {
t.Errorf("unexpected error: %v", err)
}
@@ -97,11 +95,11 @@ func TestRESTMapper(t *testing.T) {
if mapping.Resource != "replicationControllers" && mapping.Resource != "replicationcontrollers" {
t.Errorf("incorrect resource name: %#v", mapping)
}
if mapping.GroupVersionKind.GroupVersion() != currGroupVersion {
if mapping.GroupVersionKind.GroupVersion() != version {
t.Errorf("incorrect version: %v", mapping)
}
interfaces, _ := latest.GroupOrDie("").InterfacesFor(currGroupVersion.String())
interfaces, _ := latest.GroupOrDie("").InterfacesFor(version.String())
if mapping.Codec != interfaces.Codec {
t.Errorf("unexpected codec: %#v, expected: %#v", mapping, interfaces)
}

View File

@@ -109,13 +109,6 @@ type GroupMeta struct {
// GroupVersion represents the current external default version of the group.
GroupVersion unversioned.GroupVersion
// Versions is the list of versions that are recognized in code. The order
// provided is assumed to be from the oldest to the newest, e.g.,
// Versions[0] == oldest and Versions[N-1] == newest.
// Clients may choose to prefer the latter items in the list over the former
// items when presented with a set of versions to choose.
Versions []string
// GroupVersions is Group + Versions. This is to avoid string concatenation
// in many places.
GroupVersions []unversioned.GroupVersion