mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-01 07:47:56 +00:00
refactoring latest.go GroupVersion;
clean up latest.go GroupVersions; remove latest.GroupMeta.Group; remove latest.GroupMeta.Version.
This commit is contained in:
parent
851ed7a9f2
commit
6e192760e3
@ -347,13 +347,13 @@ func updateEtcdOverrides(overrides []string, storageVersions map[string]string,
|
||||
glog.Errorf("invalid api group %s: %v", group, err)
|
||||
continue
|
||||
}
|
||||
if _, found := storageVersions[apigroup.Group]; !found {
|
||||
glog.Errorf("Couldn't find the storage version for group %s", apigroup.Group)
|
||||
if _, found := storageVersions[apigroup.GroupVersion.Group]; !found {
|
||||
glog.Errorf("Couldn't find the storage version for group %s", apigroup.GroupVersion.Group)
|
||||
continue
|
||||
}
|
||||
|
||||
servers := strings.Split(tokens[1], ";")
|
||||
etcdOverrideStorage, err := newEtcdFn("", servers, apigroup.InterfacesFor, storageVersions[apigroup.Group], prefix)
|
||||
etcdOverrideStorage, err := newEtcdFn("", servers, apigroup.InterfacesFor, storageVersions[apigroup.GroupVersion.Group], prefix)
|
||||
if err != nil {
|
||||
glog.Fatalf("Invalid storage version or misconfigured etcd for %s: %v", tokens[0], err)
|
||||
}
|
||||
@ -456,10 +456,10 @@ func (s *APIServer) Run(_ []string) error {
|
||||
storageDestinations := master.NewStorageDestinations()
|
||||
|
||||
storageVersions := generateStorageVersionMap(s.DeprecatedStorageVersion, s.StorageVersions)
|
||||
if _, found := storageVersions[legacyV1Group.Group]; !found {
|
||||
glog.Fatalf("Couldn't find the storage version for group: %q in storageVersions: %v", legacyV1Group.Group, storageVersions)
|
||||
if _, found := storageVersions[legacyV1Group.GroupVersion.Group]; !found {
|
||||
glog.Fatalf("Couldn't find the storage version for group: %q in storageVersions: %v", legacyV1Group.GroupVersion.Group, storageVersions)
|
||||
}
|
||||
etcdStorage, err := newEtcd(s.EtcdConfigFile, s.EtcdServerList, legacyV1Group.InterfacesFor, storageVersions[legacyV1Group.Group], s.EtcdPathPrefix)
|
||||
etcdStorage, err := newEtcd(s.EtcdConfigFile, s.EtcdServerList, legacyV1Group.InterfacesFor, storageVersions[legacyV1Group.GroupVersion.Group], s.EtcdPathPrefix)
|
||||
if err != nil {
|
||||
glog.Fatalf("Invalid storage version or misconfigured etcd: %v", err)
|
||||
}
|
||||
@ -470,10 +470,10 @@ func (s *APIServer) Run(_ []string) error {
|
||||
if err != nil {
|
||||
glog.Fatalf("Extensions API is enabled in runtime config, but not enabled in the environment variable KUBE_API_VERSIONS. Error: %v", err)
|
||||
}
|
||||
if _, found := storageVersions[expGroup.Group]; !found {
|
||||
glog.Fatalf("Couldn't find the storage version for group: %q in storageVersions: %v", expGroup.Group, storageVersions)
|
||||
if _, found := storageVersions[expGroup.GroupVersion.Group]; !found {
|
||||
glog.Fatalf("Couldn't find the storage version for group: %q in storageVersions: %v", expGroup.GroupVersion.Group, storageVersions)
|
||||
}
|
||||
expEtcdStorage, err := newEtcd(s.EtcdConfigFile, s.EtcdServerList, expGroup.InterfacesFor, storageVersions[expGroup.Group], s.EtcdPathPrefix)
|
||||
expEtcdStorage, err := newEtcd(s.EtcdConfigFile, s.EtcdServerList, expGroup.InterfacesFor, storageVersions[expGroup.GroupVersion.Group], s.EtcdPathPrefix)
|
||||
if err != nil {
|
||||
glog.Fatalf("Invalid extensions storage version or misconfigured etcd: %v", err)
|
||||
}
|
||||
|
@ -39,7 +39,7 @@ var (
|
||||
inputSource = flag.StringP("input", "i", "-", "Input source; '-' means stdin")
|
||||
outputDest = flag.StringP("output", "o", "-", "Output destination; '-' means stdout")
|
||||
rewrite = flag.StringP("rewrite", "r", "", "If nonempty, use this as both input and output.")
|
||||
outputVersion = flag.StringP("out-version", "v", latest.GroupOrDie("").Version, "Version to convert input to")
|
||||
outputVersion = flag.StringP("out-version", "v", latest.GroupOrDie("").GroupVersion.Version, "Version to convert input to")
|
||||
)
|
||||
|
||||
// isYAML determines whether data is JSON or YAML formatted by seeing
|
||||
|
@ -49,26 +49,22 @@ func init() {
|
||||
return
|
||||
}
|
||||
|
||||
worstToBestGroupVersions := []unversioned.GroupVersion{}
|
||||
|
||||
// Use the first API version in the list of registered versions as the latest.
|
||||
registeredGroupVersions := registered.GroupVersionsForGroup("")
|
||||
groupVersion := registeredGroupVersions[0]
|
||||
*groupMeta = latest.GroupMeta{
|
||||
GroupVersion: groupVersion.String(),
|
||||
Group: groupVersion.Group,
|
||||
Version: groupVersion.Version,
|
||||
GroupVersion: groupVersion,
|
||||
Codec: runtime.CodecFor(api.Scheme, groupVersion.String()),
|
||||
}
|
||||
|
||||
var versions []string
|
||||
var groupVersions []string
|
||||
worstToBestGroupVersions := []unversioned.GroupVersion{}
|
||||
for i := len(registeredGroupVersions) - 1; i >= 0; i-- {
|
||||
versions = append(versions, registeredGroupVersions[i].Version)
|
||||
groupVersions = append(groupVersions, registeredGroupVersions[i].String())
|
||||
worstToBestGroupVersions = append(worstToBestGroupVersions, registeredGroupVersions[i])
|
||||
}
|
||||
groupMeta.Versions = versions
|
||||
groupMeta.GroupVersions = groupVersions
|
||||
groupMeta.GroupVersions = registeredGroupVersions
|
||||
|
||||
groupMeta.SelfLinker = runtime.SelfLinker(accessor)
|
||||
|
||||
|
@ -57,7 +57,7 @@ func TestCodec(t *testing.T) {
|
||||
if err := json.Unmarshal(data, &other); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if other.APIVersion != latest.GroupOrDie("").Version || other.Kind != "Pod" {
|
||||
if other.APIVersion != latest.GroupOrDie("").GroupVersion.Version || other.Kind != "Pod" {
|
||||
t.Errorf("unexpected unmarshalled object %#v", other)
|
||||
}
|
||||
}
|
||||
@ -66,7 +66,7 @@ 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("").Version}, latest.GroupOrDie("").Versions...) {
|
||||
for i, version := range append([]string{latest.GroupOrDie("").GroupVersion.Version}, latest.GroupOrDie("").Versions...) {
|
||||
if vi, err := latest.GroupOrDie("").InterfacesFor(version); err != nil || vi == nil {
|
||||
t.Fatalf("%d: unexpected result: %v", i, err)
|
||||
}
|
||||
|
@ -23,6 +23,7 @@ import (
|
||||
|
||||
"k8s.io/kubernetes/pkg/api/meta"
|
||||
"k8s.io/kubernetes/pkg/api/registered"
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
"k8s.io/kubernetes/pkg/runtime"
|
||||
)
|
||||
|
||||
@ -97,7 +98,7 @@ func (g GroupMetaMap) AllPreferredGroupVersions() string {
|
||||
}
|
||||
var defaults []string
|
||||
for _, groupMeta := range g {
|
||||
defaults = append(defaults, groupMeta.GroupVersion)
|
||||
defaults = append(defaults, groupMeta.GroupVersion.String())
|
||||
}
|
||||
sort.Strings(defaults)
|
||||
return strings.Join(defaults, ",")
|
||||
@ -105,16 +106,8 @@ func (g GroupMetaMap) AllPreferredGroupVersions() string {
|
||||
|
||||
// GroupMeta stores the metadata of a group, such as the latest supported version.
|
||||
type GroupMeta struct {
|
||||
// GroupVersion represents the current external default version of the group. It
|
||||
// is in the form of "group/version".
|
||||
GroupVersion string
|
||||
|
||||
// Version represents the current external default version of the group.
|
||||
// It equals to the "version" part of GroupVersion.
|
||||
Version string
|
||||
|
||||
// Group represents the name of the group
|
||||
Group string
|
||||
// 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.,
|
||||
@ -125,7 +118,7 @@ type GroupMeta struct {
|
||||
|
||||
// GroupVersions is Group + Versions. This is to avoid string concatenation
|
||||
// in many places.
|
||||
GroupVersions []string
|
||||
GroupVersions []unversioned.GroupVersion
|
||||
|
||||
// Codec is the default codec for serializing output that should use
|
||||
// the latest supported version. Use this Codec when writing to
|
||||
|
@ -16,7 +16,11 @@ limitations under the License.
|
||||
|
||||
package latest
|
||||
|
||||
import "testing"
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"k8s.io/kubernetes/pkg/api/unversioned"
|
||||
)
|
||||
|
||||
func TestAllPreferredGroupVersions(t *testing.T) {
|
||||
testCases := []struct {
|
||||
@ -26,13 +30,13 @@ func TestAllPreferredGroupVersions(t *testing.T) {
|
||||
{
|
||||
groupMetaMap: GroupMetaMap{
|
||||
"group1": &GroupMeta{
|
||||
GroupVersion: "group1/v1",
|
||||
GroupVersion: unversioned.GroupVersion{"group1", "v1"},
|
||||
},
|
||||
"group2": &GroupMeta{
|
||||
GroupVersion: "group2/v2",
|
||||
GroupVersion: unversioned.GroupVersion{"group2", "v2"},
|
||||
},
|
||||
"": &GroupMeta{
|
||||
GroupVersion: "v1",
|
||||
GroupVersion: unversioned.GroupVersion{"", "v1"},
|
||||
},
|
||||
},
|
||||
expect: "group1/v1,group2/v2,v1",
|
||||
@ -40,7 +44,7 @@ func TestAllPreferredGroupVersions(t *testing.T) {
|
||||
{
|
||||
groupMetaMap: GroupMetaMap{
|
||||
"": &GroupMeta{
|
||||
GroupVersion: "v1",
|
||||
GroupVersion: unversioned.GroupVersion{"", "v1"},
|
||||
},
|
||||
},
|
||||
expect: "v1",
|
||||
|
@ -64,12 +64,12 @@ func init() {
|
||||
// TODO: caesarxuchao: we need a central place to store all available API
|
||||
// groups and their metadata.
|
||||
if _, ok := Groups[""]; !ok {
|
||||
// TODO: The second latest.GroupOrDie("").Version will be latest.GroupVersion after we
|
||||
// TODO: The second latest.GroupOrDie("").GroupVersion.Version will be latest.GroupVersion after we
|
||||
// have multiple group support
|
||||
Groups[""] = TestGroup{"", latest.GroupOrDie("").Version, latest.GroupOrDie("").GroupVersion}
|
||||
Groups[""] = TestGroup{"", latest.GroupOrDie("").GroupVersion.Version, latest.GroupOrDie("").GroupVersion.String()}
|
||||
}
|
||||
if _, ok := Groups["extensions"]; !ok {
|
||||
Groups["extensions"] = TestGroup{"extensions", latest.GroupOrDie("extensions").Version, latest.GroupOrDie("extensions").GroupVersion}
|
||||
Groups["extensions"] = TestGroup{"extensions", latest.GroupOrDie("extensions").GroupVersion.Version, latest.GroupOrDie("extensions").GroupVersion.String()}
|
||||
}
|
||||
|
||||
Default = Groups[""]
|
||||
|
@ -46,25 +46,21 @@ func init() {
|
||||
return
|
||||
}
|
||||
|
||||
worstToBestGroupVersions := []unversioned.GroupVersion{}
|
||||
|
||||
registeredGroupVersions := registered.GroupVersionsForGroup("componentconfig")
|
||||
groupVersion := registeredGroupVersions[0]
|
||||
*groupMeta = latest.GroupMeta{
|
||||
GroupVersion: groupVersion.String(),
|
||||
Group: groupVersion.Group,
|
||||
Version: groupVersion.Version,
|
||||
GroupVersion: groupVersion,
|
||||
Codec: runtime.CodecFor(api.Scheme, groupVersion.String()),
|
||||
}
|
||||
|
||||
var versions []string
|
||||
var groupVersions []string
|
||||
worstToBestGroupVersions := []unversioned.GroupVersion{}
|
||||
for i := len(registeredGroupVersions) - 1; i >= 0; i-- {
|
||||
versions = append(versions, registeredGroupVersions[i].Version)
|
||||
groupVersions = append(groupVersions, registeredGroupVersions[i].String())
|
||||
worstToBestGroupVersions = append(worstToBestGroupVersions, registeredGroupVersions[i])
|
||||
}
|
||||
groupMeta.Versions = versions
|
||||
groupMeta.GroupVersions = groupVersions
|
||||
groupMeta.GroupVersions = registeredGroupVersions
|
||||
|
||||
groupMeta.SelfLinker = runtime.SelfLinker(accessor)
|
||||
|
||||
|
@ -37,7 +37,7 @@ func TestCodec(t *testing.T) {
|
||||
if err := json.Unmarshal(data, &other); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if other.APIVersion != latest.GroupOrDie("componentconfig").GroupVersion || other.Kind != "KubeProxyConfiguration" {
|
||||
if other.APIVersion != latest.GroupOrDie("componentconfig").GroupVersion.String() || other.Kind != "KubeProxyConfiguration" {
|
||||
t.Errorf("unexpected unmarshalled object %#v", other)
|
||||
}
|
||||
}
|
||||
@ -46,8 +46,8 @@ func TestInterfacesFor(t *testing.T) {
|
||||
if _, err := latest.GroupOrDie("componentconfig").InterfacesFor(""); err == nil {
|
||||
t.Fatalf("unexpected non-error: %v", err)
|
||||
}
|
||||
for i, groupVersion := range append([]string{latest.GroupOrDie("componentconfig").GroupVersion}, latest.GroupOrDie("componentconfig").GroupVersions...) {
|
||||
if vi, err := latest.GroupOrDie("componentconfig").InterfacesFor(groupVersion); err != nil || vi == nil {
|
||||
for i, groupVersion := range append([]unversioned.GroupVersion{latest.GroupOrDie("componentconfig").GroupVersion}, latest.GroupOrDie("componentconfig").GroupVersions...) {
|
||||
if vi, err := latest.GroupOrDie("componentconfig").InterfacesFor(groupVersion.String()); err != nil || vi == nil {
|
||||
t.Fatalf("%d: unexpected result: %v", i, err)
|
||||
}
|
||||
}
|
||||
|
@ -46,25 +46,21 @@ func init() {
|
||||
return
|
||||
}
|
||||
|
||||
worstToBestGroupVersions := []unversioned.GroupVersion{}
|
||||
|
||||
registeredGroupVersions := registered.GroupVersionsForGroup("extensions")
|
||||
groupVersion := registeredGroupVersions[0]
|
||||
*groupMeta = latest.GroupMeta{
|
||||
GroupVersion: groupVersion.String(),
|
||||
Group: groupVersion.Group,
|
||||
Version: groupVersion.Version,
|
||||
GroupVersion: groupVersion,
|
||||
Codec: runtime.CodecFor(api.Scheme, groupVersion.String()),
|
||||
}
|
||||
|
||||
var versions []string
|
||||
var groupVersions []string
|
||||
worstToBestGroupVersions := []unversioned.GroupVersion{}
|
||||
for i := len(registeredGroupVersions) - 1; i >= 0; i-- {
|
||||
versions = append(versions, registeredGroupVersions[i].Version)
|
||||
groupVersions = append(groupVersions, registeredGroupVersions[i].String())
|
||||
worstToBestGroupVersions = append(worstToBestGroupVersions, registeredGroupVersions[i])
|
||||
}
|
||||
groupMeta.Versions = versions
|
||||
groupMeta.GroupVersions = groupVersions
|
||||
groupMeta.GroupVersions = registeredGroupVersions
|
||||
|
||||
groupMeta.SelfLinker = runtime.SelfLinker(accessor)
|
||||
|
||||
|
@ -58,7 +58,7 @@ func TestCodec(t *testing.T) {
|
||||
if err := json.Unmarshal(data, &other); err != nil {
|
||||
t.Fatalf("unexpected error: %v", err)
|
||||
}
|
||||
if other.APIVersion != latest.GroupOrDie("extensions").GroupVersion || other.Kind != "DaemonSet" {
|
||||
if other.APIVersion != latest.GroupOrDie("extensions").GroupVersion.String() || other.Kind != "DaemonSet" {
|
||||
t.Errorf("unexpected unmarshalled object %#v", other)
|
||||
}
|
||||
}
|
||||
@ -67,8 +67,8 @@ func TestInterfacesFor(t *testing.T) {
|
||||
if _, err := latest.GroupOrDie("extensions").InterfacesFor(""); err == nil {
|
||||
t.Fatalf("unexpected non-error: %v", err)
|
||||
}
|
||||
for i, groupVersion := range append([]string{latest.GroupOrDie("extensions").GroupVersion}, latest.GroupOrDie("extensions").GroupVersions...) {
|
||||
if vi, err := latest.GroupOrDie("extensions").InterfacesFor(groupVersion); err != nil || vi == nil {
|
||||
for i, groupVersion := range append([]unversioned.GroupVersion{latest.GroupOrDie("extensions").GroupVersion}, latest.GroupOrDie("extensions").GroupVersions...) {
|
||||
if vi, err := latest.GroupOrDie("extensions").InterfacesFor(groupVersion.String()); err != nil || vi == nil {
|
||||
t.Fatalf("%d: unexpected result: %v", i, err)
|
||||
}
|
||||
}
|
||||
|
@ -46,25 +46,21 @@ func init() {
|
||||
return
|
||||
}
|
||||
|
||||
worstToBestGroupVersions := []unversioned.GroupVersion{}
|
||||
|
||||
registeredGroupVersions := registered.GroupVersionsForGroup("metrics")
|
||||
groupVersion := registeredGroupVersions[0]
|
||||
*groupMeta = latest.GroupMeta{
|
||||
GroupVersion: groupVersion.String(),
|
||||
Group: groupVersion.Group,
|
||||
Version: groupVersion.Version,
|
||||
GroupVersion: groupVersion,
|
||||
Codec: runtime.CodecFor(api.Scheme, groupVersion.String()),
|
||||
}
|
||||
|
||||
var versions []string
|
||||
var groupVersions []string
|
||||
worstToBestGroupVersions := []unversioned.GroupVersion{}
|
||||
for i := len(registeredGroupVersions) - 1; i >= 0; i-- {
|
||||
versions = append(versions, registeredGroupVersions[i].Version)
|
||||
groupVersions = append(groupVersions, registeredGroupVersions[i].String())
|
||||
worstToBestGroupVersions = append(worstToBestGroupVersions, registeredGroupVersions[i])
|
||||
}
|
||||
groupMeta.Versions = versions
|
||||
groupMeta.GroupVersions = groupVersions
|
||||
groupMeta.GroupVersions = registeredGroupVersions
|
||||
|
||||
groupMeta.SelfLinker = runtime.SelfLinker(accessor)
|
||||
|
||||
|
@ -140,11 +140,8 @@ func setExtensionsDefaults(config *Config) error {
|
||||
}
|
||||
// TODO: Unconditionally set the config.Version, until we fix the config.
|
||||
//if config.Version == "" {
|
||||
gv, err := unversioned.ParseGroupVersion(g.GroupVersion)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
config.GroupVersion = &gv
|
||||
copyGroupVersion := g.GroupVersion
|
||||
config.GroupVersion = ©GroupVersion
|
||||
//}
|
||||
|
||||
versionInterfaces, err := g.InterfacesFor(config.GroupVersion.String())
|
||||
|
@ -544,11 +544,8 @@ func defaultVersionFor(config *Config) *unversioned.GroupVersion {
|
||||
// Clients default to the preferred code API version
|
||||
// TODO: implement version negotiation (highest version supported by server)
|
||||
// TODO this drops out when groupmeta is refactored
|
||||
gv, err := unversioned.ParseGroupVersion(latest.GroupOrDie("").GroupVersion)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
return &gv
|
||||
copyGroupVersion := latest.GroupOrDie("").GroupVersion
|
||||
return ©GroupVersion
|
||||
}
|
||||
|
||||
return config.GroupVersion
|
||||
|
@ -90,7 +90,7 @@ func (c *jobs) Delete(name string, options *api.DeleteOptions) (err error) {
|
||||
return c.r.Delete().Namespace(c.ns).Resource("jobs").Name(name).Do().Error()
|
||||
}
|
||||
|
||||
body, err := api.Scheme.EncodeToVersion(options, latest.GroupOrDie("").GroupVersion)
|
||||
body, err := api.Scheme.EncodeToVersion(options, latest.GroupOrDie("").GroupVersion.String())
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ type ConvertOptions struct {
|
||||
|
||||
// Complete collects information required to run Convert command from command line.
|
||||
func (o *ConvertOptions) Complete(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []string) (err error) {
|
||||
o.outputVersion = cmdutil.OutputVersion(cmd, latest.GroupOrDie("").Version)
|
||||
o.outputVersion = cmdutil.OutputVersion(cmd, latest.GroupOrDie("").GroupVersion.Version)
|
||||
outputGV, err := unversioned.ParseGroupVersion(o.outputVersion)
|
||||
if err != nil {
|
||||
return fmt.Errorf("unable to parse group/version from %q: %v", o.outputVersion, err)
|
||||
|
@ -92,7 +92,7 @@ func RunExplain(f *cmdutil.Factory, out io.Writer, cmd *cobra.Command, args []st
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
apiV = groupMeta.GroupVersion
|
||||
apiV = groupMeta.GroupVersion.String()
|
||||
}
|
||||
swagSchema, err := kubectl.GetSwaggerSchema(apiV, client)
|
||||
if err != nil {
|
||||
|
@ -221,7 +221,7 @@ func AsVersionedObject(infos []*Info, forceList bool, version string) (runtime.O
|
||||
object = objects[0]
|
||||
} else {
|
||||
object = &api.List{Items: objects}
|
||||
converted, err := tryConvert(api.Scheme, object, version, latest.GroupOrDie("").Version)
|
||||
converted, err := tryConvert(api.Scheme, object, version, latest.GroupOrDie("").GroupVersion.Version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -78,7 +78,7 @@ func getSelfLink(name, namespace string) string {
|
||||
if len(namespace) == 0 {
|
||||
namespace = api.NamespaceDefault
|
||||
}
|
||||
selfLink = fmt.Sprintf("/api/"+latest.GroupOrDie("").Version+"/pods/namespaces/%s/%s", name, namespace)
|
||||
selfLink = fmt.Sprintf("/api/"+latest.GroupOrDie("").GroupVersion.Version+"/pods/namespaces/%s/%s", name, namespace)
|
||||
return selfLink
|
||||
}
|
||||
|
||||
|
@ -673,16 +673,16 @@ func (m *Master) init(c *Config) {
|
||||
Version: expVersion.GroupVersion.Version,
|
||||
},
|
||||
}
|
||||
storageVersion, found := c.StorageVersions[g.Group]
|
||||
storageVersion, found := c.StorageVersions[g.GroupVersion.Group]
|
||||
if !found {
|
||||
glog.Fatalf("Couldn't find storage version of group %v", g.Group)
|
||||
glog.Fatalf("Couldn't find storage version of group %v", g.GroupVersion.Group)
|
||||
}
|
||||
group := unversioned.APIGroup{
|
||||
Name: g.Group,
|
||||
Name: g.GroupVersion.Group,
|
||||
Versions: expAPIVersions,
|
||||
PreferredVersion: unversioned.GroupVersionForDiscovery{GroupVersion: storageVersion, Version: apiutil.GetVersion(storageVersion)},
|
||||
}
|
||||
apiserver.AddGroupWebService(m.handlerContainer, c.APIGroupPrefix+"/"+latest.GroupOrDie("extensions").Group, group)
|
||||
apiserver.AddGroupWebService(m.handlerContainer, c.APIGroupPrefix+"/"+latest.GroupOrDie("extensions").GroupVersion.Group, group)
|
||||
allGroups = append(allGroups, group)
|
||||
apiserver.InstallServiceErrorHandler(m.handlerContainer, m.newRequestInfoResolver(), []string{expVersion.GroupVersion.String()})
|
||||
}
|
||||
@ -1021,7 +1021,7 @@ func (m *Master) thirdpartyapi(group, kind, version string) *apiserver.APIGroupV
|
||||
strings.ToLower(kind) + "s": resourceStorage,
|
||||
}
|
||||
|
||||
serverGroupVersion := unversioned.ParseGroupVersionOrDie(latest.GroupOrDie("").GroupVersion)
|
||||
serverGroupVersion := latest.GroupOrDie("").GroupVersion
|
||||
|
||||
return &apiserver.APIGroupVersion{
|
||||
Root: apiRoot,
|
||||
@ -1111,7 +1111,7 @@ func (m *Master) experimental(c *Config) *apiserver.APIGroupVersion {
|
||||
}
|
||||
|
||||
extensionsGroup := latest.GroupOrDie("extensions")
|
||||
serverGroupVersion := unversioned.ParseGroupVersionOrDie(latest.GroupOrDie("").GroupVersion)
|
||||
serverGroupVersion := latest.GroupOrDie("").GroupVersion
|
||||
|
||||
return &apiserver.APIGroupVersion{
|
||||
Root: m.apiGroupPrefix,
|
||||
@ -1125,7 +1125,7 @@ func (m *Master) experimental(c *Config) *apiserver.APIGroupVersion {
|
||||
Codec: extensionsGroup.Codec,
|
||||
Linker: extensionsGroup.SelfLinker,
|
||||
Storage: storage,
|
||||
GroupVersion: unversioned.ParseGroupVersionOrDie(extensionsGroup.GroupVersion),
|
||||
GroupVersion: extensionsGroup.GroupVersion,
|
||||
ServerGroupVersion: &serverGroupVersion,
|
||||
|
||||
Admit: m.admissionControl,
|
||||
|
@ -354,7 +354,7 @@ func TestExpapi(t *testing.T) {
|
||||
assert.Equal(expAPIGroup.Mapper, extensionsGroupMeta.RESTMapper)
|
||||
assert.Equal(expAPIGroup.Codec, extensionsGroupMeta.Codec)
|
||||
assert.Equal(expAPIGroup.Linker, extensionsGroupMeta.SelfLinker)
|
||||
assert.Equal(expAPIGroup.GroupVersion, unversioned.GroupVersion{Group: extensionsGroupMeta.Group, Version: extensionsGroupMeta.Version})
|
||||
assert.Equal(expAPIGroup.GroupVersion, extensionsGroupMeta.GroupVersion)
|
||||
}
|
||||
|
||||
// TestGetNodeAddresses verifies that proper results are returned
|
||||
|
@ -69,7 +69,7 @@ func (t *thirdPartyResourceDataMapper) RESTMapping(gk unversioned.GroupKind, ver
|
||||
// TODO figure out why we're doing this rewriting
|
||||
extensionGK := unversioned.GroupKind{Group: "extensions", Kind: "ThirdPartyResourceData"}
|
||||
|
||||
mapping, err := t.mapper.RESTMapping(extensionGK, latest.GroupOrDie("extensions").Version)
|
||||
mapping, err := t.mapper.RESTMapping(extensionGK, latest.GroupOrDie("extensions").GroupVersion.Version)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
@ -43,7 +43,7 @@ func createDNSPod(namespace, wheezyProbeCmd, jessieProbeCmd string) *api.Pod {
|
||||
pod := &api.Pod{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: latest.GroupOrDie("").Version,
|
||||
APIVersion: latest.GroupOrDie("").GroupVersion.Version,
|
||||
},
|
||||
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("").Version,
|
||||
APIVersion: latest.GroupOrDie("").GroupVersion.Version,
|
||||
},
|
||||
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("").Version,
|
||||
APIVersion: latest.GroupOrDie("").GroupVersion.Version,
|
||||
},
|
||||
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("").Version,
|
||||
APIVersion: latest.GroupOrDie("").GroupVersion.Version,
|
||||
},
|
||||
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("").Version,
|
||||
APIVersion: latest.GroupOrDie("").GroupVersion.Version,
|
||||
},
|
||||
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("").Version,
|
||||
APIVersion: latest.GroupOrDie("").GroupVersion.Version,
|
||||
},
|
||||
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("").Version,
|
||||
APIVersion: latest.GroupOrDie("").GroupVersion.Version,
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: testPodName,
|
||||
|
@ -412,7 +412,7 @@ func testPDPod(diskNames []string, targetHost string, readOnly bool, numContaine
|
||||
pod := &api.Pod{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: latest.GroupOrDie("").Version,
|
||||
APIVersion: latest.GroupOrDie("").GroupVersion.Version,
|
||||
},
|
||||
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("").Version,
|
||||
APIVersion: latest.GroupOrDie("").GroupVersion.Version,
|
||||
},
|
||||
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("").Version,
|
||||
APIVersion: latest.GroupOrDie("").GroupVersion.Version,
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
|
@ -2053,7 +2053,7 @@ func NewHostExecPodSpec(ns, name string) *api.Pod {
|
||||
pod := &api.Pod{
|
||||
TypeMeta: unversioned.TypeMeta{
|
||||
Kind: "Pod",
|
||||
APIVersion: latest.GroupOrDie("").Version,
|
||||
APIVersion: latest.GroupOrDie("").GroupVersion.Version,
|
||||
},
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: name,
|
||||
|
@ -126,8 +126,8 @@ func startMasterOrDie(masterConfig *master.Config) (*master.Master, *httptest.Se
|
||||
if masterConfig == nil {
|
||||
etcdClient := NewEtcdClient()
|
||||
storageVersions := make(map[string]string)
|
||||
etcdStorage, err := master.NewEtcdStorage(etcdClient, latest.GroupOrDie("").InterfacesFor, latest.GroupOrDie("").GroupVersion, etcdtest.PathPrefix())
|
||||
storageVersions[""] = latest.GroupOrDie("").GroupVersion
|
||||
etcdStorage, err := master.NewEtcdStorage(etcdClient, latest.GroupOrDie("").InterfacesFor, latest.GroupOrDie("").GroupVersion.String(), etcdtest.PathPrefix())
|
||||
storageVersions[""] = latest.GroupOrDie("").GroupVersion.String()
|
||||
if err != nil {
|
||||
glog.Fatalf("Failed to create etcd storage for master %v", err)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user