update decoder to use GroupVersion

This commit is contained in:
deads2k
2015-11-17 10:07:45 -05:00
parent 3bd23b185b
commit 6231404682
12 changed files with 78 additions and 47 deletions

View File

@@ -52,6 +52,11 @@ type GroupVersion struct {
// String puts "group" and "version" into a single "group/version" string. For the legacy v1
// it returns "v1".
func (gv GroupVersion) String() string {
// special case the internal apiVersion for kube
if len(gv.Group) == 0 && len(gv.Version) == 0 {
return ""
}
// special case of "v1" for backward compatibility
if gv.Group == "" && gv.Version == "v1" {
return gv.Version
@@ -63,6 +68,11 @@ func (gv GroupVersion) String() string {
// ParseGroupVersion turns "group/version" string into a GroupVersion struct. It reports error
// if it cannot parse the string.
func ParseGroupVersion(gv string) (GroupVersion, error) {
// this can be the internal version for kube
if (len(gv) == 0) || (gv == "/") {
return GroupVersion{}, nil
}
s := strings.Split(gv, "/")
// "v1" is the only special case. Otherwise GroupVersion is expected to contain
// one "/" dividing the string into two parts.