{"modulePath":"github.com/UnityTech/client-go","version":"v2.0.0+incompatible","isLatest":false,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package meta\n\nPackage meta provides functions for retrieving API metadata from objects belonging to the Kubernetes API\n\nTODO: move everything in this file to pkg/api/rest\n\n## Constants\n\n```go\nconst (\n\tAnyGroup    = \"*\"\n\tAnyVersion  = \"*\"\n\tAnyResource = \"*\"\n\tAnyKind     = \"*\"\n)\n```\n\n## Variables\n\n```go\nvar RESTScopeNamespace = \u0026restScope{\n\tname:             RESTScopeNameNamespace,\n\tparamName:        \"namespaces\",\n\targumentName:     \"namespace\",\n\tparamDescription: \"object name and auth scope, such as for teams and projects\",\n}\n```\n\n```go\nvar RESTScopeRoot = \u0026restScope{\n\tname: RESTScopeNameRoot,\n}\n```\n\n## Functions\n\n```go\nfunc EachListItem(obj runtime.Object, fn func(runtime.Object) error) error\n```\nEachListItem invokes fn on each runtime.Object in the list. Any error immediately terminates the loop.\n\n```go\nfunc ExtractList(obj runtime.Object) ([]runtime.Object, error)\n```\nExtractList returns obj's Items element as an array of runtime.Objects. Returns an error if obj is not a List type (does not have an Items member).\n\n```go\nfunc GetItemsPtr(list runtime.Object) (interface{}, error)\n```\nGetItemsPtr returns a pointer to the list object's Items member. If 'list' doesn't have an Items member, it's not really a list type and an error will be returned. This function will either return a pointer to a slice, or an error, but not both.\n\n```go\nfunc IsAmbiguousError(err error) bool\n```\n\n```go\nfunc IsListType(obj runtime.Object) bool\n```\nIsListType returns true if the provided Object has a slice called Items\n\n```go\nfunc IsNoMatchError(err error) bool\n```\n\n```go\nfunc KindToResource(kind unversioned.GroupVersionKind) (unversioned.GroupVersionResource, unversioned.GroupVersionResource)\n```\nKindToResource converts Kind to a resource name. Broken. This method only \"sort of\" works when used outside of this package.  It assumes that Kinds and Resources match and they aren't guaranteed to do so.\n\n```go\nfunc SetList(list runtime.Object, objects []runtime.Object) error\n```\nSetList sets the given list object's Items member have the elements given in objects. Returns an error if list is not a List type (does not have an Items member), or if any of the objects are not of the right type.\n\n## Types\n\n```go\ntype AmbiguousKindError struct {\n\tPartialKind unversioned.GroupVersionKind\n\n\tMatchingResources []unversioned.GroupVersionResource\n\tMatchingKinds     []unversioned.GroupVersionKind\n}\n```\nAmbiguousKindError is returned if the RESTMapper finds multiple matches for a kind\n\n```go\nfunc (e *AmbiguousKindError) Error() string\n```\n\n```go\ntype AmbiguousResourceError struct {\n\tPartialResource unversioned.GroupVersionResource\n\n\tMatchingResources []unversioned.GroupVersionResource\n\tMatchingKinds     []unversioned.GroupVersionKind\n}\n```\nAmbiguousResourceError is returned if the RESTMapper finds multiple matches for a resource\n\n```go\nfunc (e *AmbiguousResourceError) Error() string\n```\n\n```go\ntype DefaultRESTMapper struct {\n\t// contains filtered or unexported fields\n}\n```\nDefaultRESTMapper exposes mappings between the types defined in a runtime.Scheme. It assumes that all types defined the provided scheme can be mapped with the provided MetadataAccessor and Codec interfaces.\n\nThe resource name of a Kind is defined as the lowercase, English-plural version of the Kind string. When converting from resource to Kind, the singular version of the resource name is also accepted for convenience.\n\nTODO: Only accept plural for some operations for increased control? (\\`get pod bar\\` vs \\`get pods bar\\`)\n\n```go\nfunc NewDefaultRESTMapper(defaultGroupVersions []unversioned.GroupVersion, f VersionInterfacesFunc) *DefaultRESTMapper\n```\nNewDefaultRESTMapper initializes a mapping between Kind and APIVersion to a resource name and back based on the objects in a runtime.Scheme and the Kubernetes API conventions. Takes a group name, a priority list of the versions to search when an object has no default version (set empty to return an error), and a function that retrieves the correct metadata for a given version.\n\n```go\nfunc (m *DefaultRESTMapper) Add(kind unversioned.GroupVersionKind, scope RESTScope)\n```\n\n```go\nfunc (m *DefaultRESTMapper) AddResourceAlias(alias string, resources ...string)\n```\nAddResourceAlias maps aliases to resources\n\n```go\nfunc (m *DefaultRESTMapper) AliasesForResource(alias string) ([]string, bool)\n```\nAliasesForResource returns whether a resource has an alias or not\n\n```go\nfunc (m *DefaultRESTMapper) KindFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionKind, error)\n```\n\n```go\nfunc (m *DefaultRESTMapper) KindsFor(input unversioned.GroupVersionResource) ([]unversioned.GroupVersionKind, error)\n```\n\n```go\nfunc (m *DefaultRESTMapper) RESTMapping(gk unversioned.GroupKind, versions ...string) (*RESTMapping, error)\n```\nRESTMapping returns a struct representing the resource path and conversion interfaces a RESTClient should use to operate on the provided group/kind in order of versions. If a version search order is not provided, the search order provided to DefaultRESTMapper will be used to resolve which version should be used to access the named group/kind. TODO: consider refactoring to use RESTMappings in a way that preserves version ordering and preference\n\n```go\nfunc (m *DefaultRESTMapper) RESTMappings(gk unversioned.GroupKind) ([]*RESTMapping, error)\n```\nRESTMappings returns the RESTMappings for the provided group kind in a rough internal preferred order. If no kind is found it will return a NoResourceMatchError.\n\n```go\nfunc (m *DefaultRESTMapper) ResourceFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionResource, error)\n```\n\n```go\nfunc (m *DefaultRESTMapper) ResourceSingularizer(resourceType string) (string, error)\n```\nResourceSingularizer implements RESTMapper It converts a resource name from plural to singular (e.g., from pods to pod)\n\n```go\nfunc (m *DefaultRESTMapper) ResourcesFor(input unversioned.GroupVersionResource) ([]unversioned.GroupVersionResource, error)\n```\n\n```go\nfunc (m *DefaultRESTMapper) String() string\n```\n\n```go\ntype FirstHitRESTMapper struct {\n\tMultiRESTMapper\n}\n```\nFirstHitRESTMapper is a wrapper for multiple RESTMappers which returns the first successful result for the singular requests\n\n```go\nfunc (m FirstHitRESTMapper) KindFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionKind, error)\n```\n\n```go\nfunc (m FirstHitRESTMapper) RESTMapping(gk unversioned.GroupKind, versions ...string) (*RESTMapping, error)\n```\nRESTMapping provides the REST mapping for the resource based on the kind and version. This implementation supports multiple REST schemas and return the first match.\n\n```go\nfunc (m FirstHitRESTMapper) ResourceFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionResource, error)\n```\n\n```go\nfunc (m FirstHitRESTMapper) String() string\n```\n\n```go\ntype List unversioned.List\n```\nList lets you work with list metadata from any of the versioned or internal API objects. Attempting to set or retrieve a field on an object that does not support that field will be a no-op and return a default value.\n\n```go\nfunc ListAccessor(obj interface{}) (List, error)\n```\nListAccessor returns a List interface for the provided object or an error if the object does not provide List. IMPORTANT: Objects are a superset of lists, so all Objects return List metadata. Do not use this check to determine whether an object \\*is\\* a List. TODO: return bool instead of error\n\n```go\ntype ListMetaAccessor interface {\n\tGetListMeta() List\n}\n```\n\n```go\ntype MetadataAccessor interface {\n\tAPIVersion(obj runtime.Object) (string, error)\n\tSetAPIVersion(obj runtime.Object, version string) error\n\n\tKind(obj runtime.Object) (string, error)\n\tSetKind(obj runtime.Object, kind string) error\n\n\tNamespace(obj runtime.Object) (string, error)\n\tSetNamespace(obj runtime.Object, namespace string) error\n\n\tName(obj runtime.Object) (string, error)\n\tSetName(obj runtime.Object, name string) error\n\n\tGenerateName(obj runtime.Object) (string, error)\n\tSetGenerateName(obj runtime.Object, name string) error\n\n\tUID(obj runtime.Object) (types.UID, error)\n\tSetUID(obj runtime.Object, uid types.UID) error\n\n\tSelfLink(obj runtime.Object) (string, error)\n\tSetSelfLink(obj runtime.Object, selfLink string) error\n\n\tLabels(obj runtime.Object) (map[string]string, error)\n\tSetLabels(obj runtime.Object, labels map[string]string) error\n\n\tAnnotations(obj runtime.Object) (map[string]string, error)\n\tSetAnnotations(obj runtime.Object, annotations map[string]string) error\n\n\truntime.ResourceVersioner\n}\n```\nMetadataAccessor lets you work with object and list metadata from any of the versioned or internal API objects. Attempting to set or retrieve a field on an object that does not support that field (Name, UID, Namespace on lists) will be a no-op and return a default value.\n\nMetadataAccessor exposes Interface in a way that can be used with multiple objects.\n\n```go\nfunc NewAccessor() MetadataAccessor\n```\nNewAccessor returns a MetadataAccessor that can retrieve or manipulate resource version on objects derived from core API metadata concepts.\n\n```go\ntype MultiRESTMapper []RESTMapper\n```\nMultiRESTMapper is a wrapper for multiple RESTMappers.\n\n```go\nfunc (m MultiRESTMapper) AliasesForResource(alias string) ([]string, bool)\n```\nAliasesForResource finds the first alias response for the provided mappers.\n\n```go\nfunc (m MultiRESTMapper) KindFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionKind, error)\n```\n\n```go\nfunc (m MultiRESTMapper) KindsFor(resource unversioned.GroupVersionResource) (gvk []unversioned.GroupVersionKind, err error)\n```\n\n```go\nfunc (m MultiRESTMapper) RESTMapping(gk unversioned.GroupKind, versions ...string) (*RESTMapping, error)\n```\nRESTMapping provides the REST mapping for the resource based on the kind and version. This implementation supports multiple REST schemas and return the first match.\n\n```go\nfunc (m MultiRESTMapper) RESTMappings(gk unversioned.GroupKind) ([]*RESTMapping, error)\n```\nRESTMappings returns all possible RESTMappings for the provided group kind, or an error if the type is not recognized.\n\n```go\nfunc (m MultiRESTMapper) ResourceFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionResource, error)\n```\n\n```go\nfunc (m MultiRESTMapper) ResourceSingularizer(resource string) (singular string, err error)\n```\nResourceSingularizer converts a REST resource name from plural to singular (e.g., from pods to pod) This implementation supports multiple REST schemas and return the first match.\n\n```go\nfunc (m MultiRESTMapper) ResourcesFor(resource unversioned.GroupVersionResource) ([]unversioned.GroupVersionResource, error)\n```\n\n```go\nfunc (m MultiRESTMapper) String() string\n```\n\n```go\ntype NoKindMatchError struct {\n\tPartialKind unversioned.GroupVersionKind\n}\n```\nNoKindMatchError is returned if the RESTMapper can't find any match for a kind\n\n```go\nfunc (e *NoKindMatchError) Error() string\n```\n\n```go\ntype NoResourceMatchError struct {\n\tPartialResource unversioned.GroupVersionResource\n}\n```\nNoResourceMatchError is returned if the RESTMapper can't find any match for a resource\n\n```go\nfunc (e *NoResourceMatchError) Error() string\n```\n\n```go\ntype Object interface {\n\tGetNamespace() string\n\tSetNamespace(namespace string)\n\tGetName() string\n\tSetName(name string)\n\tGetGenerateName() string\n\tSetGenerateName(name string)\n\tGetUID() types.UID\n\tSetUID(uid types.UID)\n\tGetResourceVersion() string\n\tSetResourceVersion(version string)\n\tGetSelfLink() string\n\tSetSelfLink(selfLink string)\n\tGetCreationTimestamp() unversioned.Time\n\tSetCreationTimestamp(timestamp unversioned.Time)\n\tGetDeletionTimestamp() *unversioned.Time\n\tSetDeletionTimestamp(timestamp *unversioned.Time)\n\tGetLabels() map[string]string\n\tSetLabels(labels map[string]string)\n\tGetAnnotations() map[string]string\n\tSetAnnotations(annotations map[string]string)\n\tGetFinalizers() []string\n\tSetFinalizers(finalizers []string)\n\tGetOwnerReferences() []metatypes.OwnerReference\n\tSetOwnerReferences([]metatypes.OwnerReference)\n\tGetClusterName() string\n\tSetClusterName(clusterName string)\n}\n```\nObject lets you work with object metadata from any of the versioned or internal API objects. Attempting to set or retrieve a field on an object that does not support that field (Name, UID, Namespace on lists) will be a no-op and return a default value.\n\n```go\nfunc Accessor(obj interface{}) (Object, error)\n```\nAccessor takes an arbitrary object pointer and returns meta.Interface. obj must be a pointer to an API type. An error is returned if the minimum required fields are missing. Fields that are not required return the default value and are a no-op if set. TODO: return bool instead of error\n\n```go\ntype ObjectMetaAccessor interface {\n\tGetObjectMeta() Object\n}\n```\n\n```go\ntype PriorityRESTMapper struct {\n\t// Delegate is the RESTMapper to use to locate all the Kind and Resource matches\n\tDelegate RESTMapper\n\n\t// ResourcePriority is a list of priority patterns to apply to matching resources.\n\t// The list of all matching resources is narrowed based on the patterns until only one remains.\n\t// A pattern with no matches is skipped.  A pattern with more than one match uses its\n\t// matches as the list to continue matching against.\n\tResourcePriority []unversioned.GroupVersionResource\n\n\t// KindPriority is a list of priority patterns to apply to matching kinds.\n\t// The list of all matching kinds is narrowed based on the patterns until only one remains.\n\t// A pattern with no matches is skipped.  A pattern with more than one match uses its\n\t// matches as the list to continue matching against.\n\tKindPriority []unversioned.GroupVersionKind\n}\n```\nPriorityRESTMapper is a wrapper for automatically choosing a particular Resource or Kind when multiple matches are possible\n\n```go\nfunc (m PriorityRESTMapper) AliasesForResource(alias string) (aliases []string, ok bool)\n```\n\n```go\nfunc (m PriorityRESTMapper) KindFor(partiallySpecifiedResource unversioned.GroupVersionResource) (unversioned.GroupVersionKind, error)\n```\nKindFor finds all kinds, then passes them through the KindPriority patterns to find a single matching hit.\n\n```go\nfunc (m PriorityRESTMapper) KindsFor(partiallySpecifiedResource unversioned.GroupVersionResource) (gvk []unversioned.GroupVersionKind, err error)\n```\n\n```go\nfunc (m PriorityRESTMapper) RESTMapping(gk unversioned.GroupKind, versions ...string) (mapping *RESTMapping, err error)\n```\n\n```go\nfunc (m PriorityRESTMapper) RESTMappings(gk unversioned.GroupKind) ([]*RESTMapping, error)\n```\n\n```go\nfunc (m PriorityRESTMapper) ResourceFor(partiallySpecifiedResource unversioned.GroupVersionResource) (unversioned.GroupVersionResource, error)\n```\nResourceFor finds all resources, then passes them through the ResourcePriority patterns to find a single matching hit.\n\n```go\nfunc (m PriorityRESTMapper) ResourceSingularizer(resource string) (singular string, err error)\n```\n\n```go\nfunc (m PriorityRESTMapper) ResourcesFor(partiallySpecifiedResource unversioned.GroupVersionResource) ([]unversioned.GroupVersionResource, error)\n```\n\n```go\nfunc (m PriorityRESTMapper) String() string\n```\n\n```go\ntype RESTMapper interface {\n\t// KindFor takes a partial resource and returns the single match.  Returns an error if there are multiple matches\n\tKindFor(resource unversioned.GroupVersionResource) (unversioned.GroupVersionKind, error)\n\n\t// KindsFor takes a partial resource and returns the list of potential kinds in priority order\n\tKindsFor(resource unversioned.GroupVersionResource) ([]unversioned.GroupVersionKind, error)\n\n\t// ResourceFor takes a partial resource and returns the single match.  Returns an error if there are multiple matches\n\tResourceFor(input unversioned.GroupVersionResource) (unversioned.GroupVersionResource, error)\n\n\t// ResourcesFor takes a partial resource and returns the list of potential resource in priority order\n\tResourcesFor(input unversioned.GroupVersionResource) ([]unversioned.GroupVersionResource, error)\n\n\t// RESTMapping identifies a preferred resource mapping for the provided group kind.\n\tRESTMapping(gk unversioned.GroupKind, versions ...string) (*RESTMapping, error)\n\t// RESTMappings returns all resource mappings for the provided group kind.\n\tRESTMappings(gk unversioned.GroupKind) ([]*RESTMapping, error)\n\n\tAliasesForResource(resource string) ([]string, bool)\n\tResourceSingularizer(resource string) (singular string, err error)\n}\n```\nRESTMapper allows clients to map resources to kind, and map kind and version to interfaces for manipulating those objects. It is primarily intended for consumers of Kubernetes compatible REST APIs as defined in docs/devel/api-conventions.md.\n\nThe Kubernetes API provides versioned resources and object kinds which are scoped to API groups. In other words, kinds and resources should not be assumed to be unique across groups.\n\nTODO: split into sub-interfaces\n\n```go\ntype RESTMapping struct {\n\t// Resource is a string representing the name of this resource as a REST client would see it\n\tResource string\n\n\tGroupVersionKind unversioned.GroupVersionKind\n\n\t// Scope contains the information needed to deal with REST Resources that are in a resource hierarchy\n\tScope RESTScope\n\n\truntime.ObjectConvertor\n\tMetadataAccessor\n}\n```\nRESTMapping contains the information needed to deal with objects of a specific resource and kind in a RESTful manner.\n\n```go\ntype RESTScope interface {\n\t// Name of the scope\n\tName() RESTScopeName\n\t// ParamName is the optional name of the parameter that should be inserted in the resource url\n\t// If empty, no param will be inserted\n\tParamName() string\n\t// ArgumentName is the optional name that should be used for the variable holding the value.\n\tArgumentName() string\n\t// ParamDescription is the optional description to use to document the parameter in api documentation\n\tParamDescription() string\n}\n```\nRESTScope contains the information needed to deal with REST resources that are in a resource hierarchy\n\n```go\ntype RESTScopeName string\n```\n\n```go\nconst (\n\tRESTScopeNameNamespace RESTScopeName = \"namespace\"\n\tRESTScopeNameRoot      RESTScopeName = \"root\"\n)\n```\n\n```go\ntype Type unversioned.Type\n```\nType exposes the type and APIVersion of versioned or internal API objects.\n\n```go\nfunc TypeAccessor(obj interface{}) (Type, error)\n```\nTypeAccessor returns an interface that allows retrieving and modifying the APIVersion and Kind of an in-memory internal object. TODO: this interface is used to test code that does not have ObjectMeta or ListMeta in round tripping (objects which can use apiVersion/kind, but do not fit the Kube api conventions).\n\n```go\ntype VersionInterfaces struct {\n\truntime.ObjectConvertor\n\tMetadataAccessor\n}\n```\nVersionInterfaces contains the interfaces one should use for dealing with types of a particular version.\n\n```go\nfunc InterfacesForUnstructured(unversioned.GroupVersion) (*VersionInterfaces, error)\n```\nInterfacesForUnstructured returns VersionInterfaces suitable for dealing with runtime.Unstructured objects.\n\n```go\ntype VersionInterfacesFunc func(version unversioned.GroupVersion) (*VersionInterfaces, error)\n```\nVersionInterfacesFunc returns the appropriate typer, and metadata accessor for a given api version, or an error if no such api version exists.\n\n","path":"github.com/UnityTech/client-go/pkg/api/meta","name":"meta","synopsis":"Package meta provides functions for retrieving API metadata from objects belonging to the Kubernetes API TODO: move everything in this file to pkg/api/rest","isRedistributable":true}
