kubernetes: github.com/erimatnor/kubernetes/pkg/api/meta Index | Files

package meta

import "github.com/erimatnor/kubernetes/pkg/api/meta"

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

Index

Package Files

doc.go interfaces.go meta.go restmapper.go

Variables

var RESTScopeNamespace = &restScope{
    name:             RESTScopeNameNamespace,
    paramName:        "namespaces",
    paramPath:        true,
    paramDescription: "object name and auth scope, such as for teams and projects",
}
var RESTScopeNamespaceLegacy = &restScope{
    name:             RESTScopeNameNamespace,
    paramName:        "namespace",
    paramPath:        false,
    paramDescription: "object name and auth scope, such as for teams and projects",
}
var RESTScopeRoot = &restScope{
    name: RESTScopeNameRoot,
}

type DefaultRESTMapper Uses

type DefaultRESTMapper struct {
    // contains filtered or unexported fields
}

DefaultRESTMapper 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.

The resource name of a Kind is defined as the lowercase, English-plural version of the Kind string in v1beta3 and onwards, and as the camelCase version of the name in v1beta1 and v1beta2. When converting from resource to Kind, the singular version of the resource name is also accepted for convenience.

TODO: Only accept plural for some operations for increased control? (`get pod bar` vs `get pods bar`)

func NewDefaultRESTMapper Uses

func NewDefaultRESTMapper(versions []string, f VersionInterfacesFunc) *DefaultRESTMapper

NewDefaultRESTMapper 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 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 codec and metadata for a given version.

func (*DefaultRESTMapper) Add Uses

func (m *DefaultRESTMapper) Add(scope RESTScope, kind string, version string, mixedCase bool)

func (*DefaultRESTMapper) AddResourceAlias Uses

func (m *DefaultRESTMapper) AddResourceAlias(alias string, resources ...string)

AddResourceAlias maps aliases to resources

func (*DefaultRESTMapper) AliasesForResource Uses

func (m *DefaultRESTMapper) AliasesForResource(alias string) ([]string, bool)

AliasesForResource returns whether a resource has an alias or not

func (*DefaultRESTMapper) RESTMapping Uses

func (m *DefaultRESTMapper) RESTMapping(kind string, versions ...string) (*RESTMapping, error)

RESTMapping returns a struct representing the resource path and conversion interfaces a RESTClient should use to operate on the provided 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 APIVersion should be used to access the named kind.

func (*DefaultRESTMapper) VersionAndKindForResource Uses

func (m *DefaultRESTMapper) VersionAndKindForResource(resource string) (defaultVersion, kind string, err error)

VersionAndKindForResource implements RESTMapper

type Interface Uses

type Interface interface {
    TypeInterface

    Namespace() string
    SetNamespace(namespace string)
    Name() string
    SetName(name string)
    GenerateName() string
    SetGenerateName(name string)
    UID() types.UID
    SetUID(uid types.UID)
    ResourceVersion() string
    SetResourceVersion(version string)
    SelfLink() string
    SetSelfLink(selfLink string)
    Labels() map[string]string
    SetLabels(labels map[string]string)
    Annotations() map[string]string
    SetAnnotations(annotations map[string]string)
}

Interface 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. TODO: rename to ObjectInterface when we clear up these interfaces.

func Accessor Uses

func Accessor(obj interface{}) (Interface, error)

Accessor 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: add a fast path for *TypeMeta and *ObjectMeta for internal objects

type MetadataAccessor Uses

type MetadataAccessor interface {
    APIVersion(obj runtime.Object) (string, error)
    SetAPIVersion(obj runtime.Object, version string) error

    Kind(obj runtime.Object) (string, error)
    SetKind(obj runtime.Object, kind string) error

    Namespace(obj runtime.Object) (string, error)
    SetNamespace(obj runtime.Object, namespace string) error

    Name(obj runtime.Object) (string, error)
    SetName(obj runtime.Object, name string) error

    GenerateName(obj runtime.Object) (string, error)
    SetGenerateName(obj runtime.Object, name string) error

    UID(obj runtime.Object) (types.UID, error)
    SetUID(obj runtime.Object, uid types.UID) error

    SelfLink(obj runtime.Object) (string, error)
    SetSelfLink(obj runtime.Object, selfLink string) error

    Labels(obj runtime.Object) (map[string]string, error)
    SetLabels(obj runtime.Object, labels map[string]string) error

    Annotations(obj runtime.Object) (map[string]string, error)
    SetAnnotations(obj runtime.Object, annotations map[string]string) error

    runtime.ResourceVersioner
}

MetadataAccessor 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.

MetadataAccessor exposes Interface in a way that can be used with multiple objects.

func NewAccessor Uses

func NewAccessor() MetadataAccessor

NewAccessor returns a MetadataAccessor that can retrieve or manipulate resource version on objects derived from core API metadata concepts.

type MultiRESTMapper Uses

type MultiRESTMapper []RESTMapper

MultiRESTMapper is a wrapper for multiple RESTMappers.

func (MultiRESTMapper) AliasesForResource Uses

func (m MultiRESTMapper) AliasesForResource(alias string) (aliases []string, ok bool)

AliasesForResource finds the first alias response for the provided mappers.

func (MultiRESTMapper) RESTMapping Uses

func (m MultiRESTMapper) RESTMapping(kind string, versions ...string) (mapping *RESTMapping, err error)

RESTMapping provides the REST mapping for the resource based on the resource kind and version. This implementation supports multiple REST schemas and return the first match.

func (MultiRESTMapper) VersionAndKindForResource Uses

func (m MultiRESTMapper) VersionAndKindForResource(resource string) (defaultVersion, kind string, err error)

VersionAndKindForResource provides the Version and Kind mappings for the REST resources. This implementation supports multiple REST schemas and return the first match.

type RESTMapper Uses

type RESTMapper interface {
    VersionAndKindForResource(resource string) (defaultVersion, kind string, err error)
    RESTMapping(kind string, versions ...string) (*RESTMapping, error)
    AliasesForResource(resource string) ([]string, bool)
}

RESTMapper 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/api-conventions.md.

type RESTMapping Uses

type RESTMapping struct {
    // Resource is a string representing the name of this resource as a REST client would see it
    Resource string
    // APIVersion represents the APIVersion that represents the resource as presented. It is provided
    // for convenience for passing around a consistent mapping.
    APIVersion string
    Kind       string

    // Scope contains the information needed to deal with REST Resources that are in a resource hierarchy
    Scope RESTScope

    runtime.Codec
    runtime.ObjectConvertor
    MetadataAccessor
}

RESTMapping contains the information needed to deal with objects of a specific resource and kind in a RESTful manner.

type RESTScope Uses

type RESTScope interface {
    // Name of the scope
    Name() RESTScopeName
    // ParamName is the optional name of the parameter that should be inserted in the resource url
    // If empty, no param will be inserted
    ParamName() string
    // ParamPath is a boolean that controls how the parameter is manifested in resource paths
    // If true, this parameter is encoded in path (i.e. /{paramName}/{paramValue})
    // If false, this parameter is encoded in query (i.e. ?{paramName}={paramValue})
    ParamPath() bool
    // ParamDescription is the optional description to use to document the parameter in api documentation
    ParamDescription() string
}

RESTScope contains the information needed to deal with REST resources that are in a resource hierarchy TODO After we deprecate v1beta1 and v1beta2, we can look a supporting removing the flexibility of supporting either a query or path param, and instead just support path param

type RESTScopeName Uses

type RESTScopeName string
const (
    RESTScopeNameNamespace RESTScopeName = "namespace"
    RESTScopeNameRoot      RESTScopeName = "root"
)

type TypeInterface Uses

type TypeInterface interface {
    APIVersion() string
    SetAPIVersion(version string)
    Kind() string
    SetKind(kind string)
}

TypeInterface exposes the type and APIVersion of versioned or internal API objects.

func TypeAccessor Uses

func TypeAccessor(obj interface{}) (TypeInterface, error)

TypeAccessor 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).

type VersionInterfaces Uses

type VersionInterfaces struct {
    runtime.Codec
    runtime.ObjectConvertor
    MetadataAccessor
}

VersionInterfaces contains the interfaces one should use for dealing with types of a particular version.

type VersionInterfacesFunc Uses

type VersionInterfacesFunc func(apiVersion string) (*VersionInterfaces, bool)

VersionInterfacesFunc returns the appropriate codec, typer, and metadata accessor for a given api version, or false if no such api version exists.

Package meta imports 6 packages (graph). Updated 2017-05-11. Refresh now. Tools for package owners.