From fb360bca98c0044e20508a6e324876a508936ea7 Mon Sep 17 00:00:00 2001 From: Chao Xu Date: Thu, 5 Nov 2015 14:15:01 -0800 Subject: [PATCH] add comments --- pkg/api/unversioned/group_version.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/pkg/api/unversioned/group_version.go b/pkg/api/unversioned/group_version.go index 1427a03c666..d5331541845 100644 --- a/pkg/api/unversioned/group_version.go +++ b/pkg/api/unversioned/group_version.go @@ -23,11 +23,14 @@ import ( ) // TODO: We need to remove the GroupVersion in types.go. We use the name GroupAndVersion here temporarily. +// GroupVersion contains the "group" and the "version", which uniquely identifies the API. type GroupAndVersion struct { Group string Version string } +// String puts "group" and "version" into a single "group/version" string. For the legacy v1 +// it returns "v1". func (gv *GroupAndVersion) String() string { // special case of "v1" for backward compatibility if gv.Group == "" && gv.Version == "v1" { @@ -37,6 +40,8 @@ func (gv *GroupAndVersion) String() string { } } +// ParseGroupVersion turns "group/version" string into a GroupVersion struct. It reports error +// if it cannot parse the string. func ParseGroupVersion(gv string) (GroupAndVersion, error) { s := strings.Split(gv, "/") // "v1" is the only special case. Otherwise GroupVersion is expected to contain