Remove ExpStorageVersion and Add StorageVersions to APIServer struct

This commit is contained in:
Chao Xu
2015-09-21 15:57:05 -07:00
parent 1b8727ada1
commit c449baea46
5 changed files with 153 additions and 16 deletions

View File

@@ -18,6 +18,8 @@ package latest
import (
"fmt"
"sort"
"strings"
"k8s.io/kubernetes/pkg/api/meta"
"k8s.io/kubernetes/pkg/api/registered"
@@ -32,6 +34,9 @@ var (
RegisterGroup = allGroups.RegisterGroup
// GroupOrDie is a shortcut to allGroups.GroupOrDie.
GroupOrDie = allGroups.GroupOrDie
// AllPreferredGroupVersions returns the preferred versions of all
// registered groups in the form of "group1/version1,group2/version2,..."
AllPreferredGroupVersions = allGroups.AllPreferredGroupVersions
)
// GroupMetaMap is a map between group names and their metadata.
@@ -76,6 +81,20 @@ func (g GroupMetaMap) GroupOrDie(group string) *GroupMeta {
return groupMeta
}
// AllPreferredGroupVersions returns the preferred versions of all registered
// groups in the form of "group1/version1,group2/version2,..."
func (g GroupMetaMap) AllPreferredGroupVersions() string {
if len(g) == 0 {
return ""
}
var defaults []string
for _, groupMeta := range g {
defaults = append(defaults, groupMeta.GroupVersion)
}
sort.Strings(defaults)
return strings.Join(defaults, ",")
}
// 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