// ParseResourceArg takes the common style of string which may be either `resource.group.com` or `resource.version.group.com` // and parses it out into both possibilities. This code takes no responsibility for knowing which representation was intended // but with a knowledge of all GroupVersions, calling code can take a very good guess. If there are only two segments, then // `*GroupVersionResource` is nil. // `resource.group.com` -> `group=com, version=group, resource=resource` and `group=group.com, resource=resource` func ParseResourceArg(arg string) (*GroupVersionResource, GroupResource) { … } // ParseKindArg takes the common style of string which may be either `Kind.group.com` or `Kind.version.group.com` // and parses it out into both possibilities. This code takes no responsibility for knowing which representation was intended // but with a knowledge of all GroupKinds, calling code can take a very good guess. If there are only two segments, then // `*GroupVersionKind` is nil. // `Kind.group.com` -> `group=com, version=group, kind=Kind` and `group=group.com, kind=Kind` func ParseKindArg(arg string) (*GroupVersionKind, GroupKind) { … } type GroupResource … func (gr GroupResource) WithVersion(version string) GroupVersionResource { … } func (gr GroupResource) Empty() bool { … } func (gr GroupResource) String() string { … } func ParseGroupKind(gk string) GroupKind { … } // ParseGroupResource turns "resource.group" string into a GroupResource struct. Empty strings are allowed // for each field. func ParseGroupResource(gr string) GroupResource { … } type GroupVersionResource … func (gvr GroupVersionResource) Empty() bool { … } func (gvr GroupVersionResource) GroupResource() GroupResource { … } func (gvr GroupVersionResource) GroupVersion() GroupVersion { … } func (gvr GroupVersionResource) String() string { … } type GroupKind … func (gk GroupKind) Empty() bool { … } func (gk GroupKind) WithVersion(version string) GroupVersionKind { … } func (gk GroupKind) String() string { … } type GroupVersionKind … // Empty returns true if group, version, and kind are empty func (gvk GroupVersionKind) Empty() bool { … } func (gvk GroupVersionKind) GroupKind() GroupKind { … } func (gvk GroupVersionKind) GroupVersion() GroupVersion { … } func (gvk GroupVersionKind) String() string { … } type GroupVersion … // Empty returns true if group and version are empty func (gv GroupVersion) Empty() bool { … } // String puts "group" and "version" into a single "group/version" string. For the legacy v1 // it returns "v1". func (gv GroupVersion) String() string { … } // Identifier implements runtime.GroupVersioner interface. func (gv GroupVersion) Identifier() string { … } // KindForGroupVersionKinds identifies the preferred GroupVersionKind out of a list. It returns ok false // if none of the options match the group. It prefers a match to group and version over just group. // TODO: Move GroupVersion to a package under pkg/runtime, since it's used by scheme. // TODO: Introduce an adapter type between GroupVersion and runtime.GroupVersioner, and use LegacyCodec(GroupVersion) // in fewer places. func (gv GroupVersion) KindForGroupVersionKinds(kinds []GroupVersionKind) (target GroupVersionKind, ok bool) { … } // ParseGroupVersion turns "group/version" string into a GroupVersion struct. It reports error // if it cannot parse the string. func ParseGroupVersion(gv string) (GroupVersion, error) { … } // WithKind creates a GroupVersionKind based on the method receiver's GroupVersion and the passed Kind. func (gv GroupVersion) WithKind(kind string) GroupVersionKind { … } // WithResource creates a GroupVersionResource based on the method receiver's GroupVersion and the passed Resource. func (gv GroupVersion) WithResource(resource string) GroupVersionResource { … } type GroupVersions … // Identifier implements runtime.GroupVersioner interface. func (gvs GroupVersions) Identifier() string { … } // KindForGroupVersionKinds identifies the preferred GroupVersionKind out of a list. It returns ok false // if none of the options match the group. func (gvs GroupVersions) KindForGroupVersionKinds(kinds []GroupVersionKind) (GroupVersionKind, bool) { … } // bestMatch tries to pick best matching GroupVersionKind and falls back to the first // found if no exact match exists. func bestMatch(kinds []GroupVersionKind, targets []GroupVersionKind) GroupVersionKind { … } // ToAPIVersionAndKind is a convenience method for satisfying runtime.Object on types that // do not use TypeMeta. func (gvk GroupVersionKind) ToAPIVersionAndKind() (string, string) { … } // FromAPIVersionAndKind returns a GVK representing the provided fields for types that // do not use TypeMeta. This method exists to support test types and legacy serializations // that have a distinct group and kind. // TODO: further reduce usage of this method. func FromAPIVersionAndKind(apiVersion, kind string) GroupVersionKind { … }