client-go: k8s.io/client-go/discovery Index | Files | Directories

package discovery

import "k8s.io/client-go/discovery"

Package transport provides a round tripper capable of caching HTTP responses.

Index

Package Files

cached_discovery.go discovery_client.go helper.go round_tripper.go unstructured.go

func FilteredBy Uses

func FilteredBy(pred ResourcePredicate, rls []*metav1.APIResourceList) []*metav1.APIResourceList

FilteredBy filters by the given predicate. Empty APIResourceLists are dropped.

func GroupVersionResources Uses

func GroupVersionResources(rls []*metav1.APIResourceList) (map[schema.GroupVersionResource]struct{}, error)

GroupVersionResources converts APIResourceLists to the GroupVersionResources.

func IsGroupDiscoveryFailedError Uses

func IsGroupDiscoveryFailedError(err error) bool

IsGroupDiscoveryFailedError returns true if the provided error indicates the server was unable to discover a complete list of APIs for the client to use.

func MatchesServerVersion Uses

func MatchesServerVersion(clientVersion apimachineryversion.Info, client DiscoveryInterface) error

MatchesServerVersion queries the server to compares the build version (git hash) of the client with the server's build version. It returns an error if it failed to contact the server or if the versions are not an exact match.

func ServerPreferredNamespacedResources Uses

func ServerPreferredNamespacedResources(d DiscoveryInterface) ([]*metav1.APIResourceList, error)

ServerPreferredNamespacedResources uses the provided discovery interface to look up preferred namespaced resources

func ServerPreferredResources Uses

func ServerPreferredResources(d DiscoveryInterface) ([]*metav1.APIResourceList, error)

ServerPreferredResources uses the provided discovery interface to look up preferred resources

func ServerResources Uses

func ServerResources(d DiscoveryInterface) ([]*metav1.APIResourceList, error)

ServerResources uses the provided discovery interface to look up supported resources for all groups and versions.

func ServerSupportsVersion Uses

func ServerSupportsVersion(client DiscoveryInterface, requiredGV schema.GroupVersion) error

ServerSupportsVersion returns an error if the server doesn't have the required version

type CachedDiscoveryClient Uses

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

CachedDiscoveryClient implements the functions that discovery server-supported API groups, versions and resources.

func NewCachedDiscoveryClientForConfig Uses

func NewCachedDiscoveryClientForConfig(config *restclient.Config, discoveryCacheDir, httpCacheDir string, ttl time.Duration) (*CachedDiscoveryClient, error)

NewCachedDiscoveryClientForConfig creates a new DiscoveryClient for the given config, and wraps the created client in a CachedDiscoveryClient. The provided configuration is updated with a custom transport that understands cache responses. We receive two distinct cache directories for now, in order to preserve old behavior which makes use of the --cache-dir flag value for storing cache data from the CacheRoundTripper, and makes use of the hardcoded destination (~/.kube/cache/discovery/...) for storing CachedDiscoveryClient cache data. If httpCacheDir is empty, the restconfig's transport will not be updated with a roundtripper that understands cache responses. If discoveryCacheDir is empty, cached server resource data will be looked up in the current directory. TODO(juanvallejo): the value of "--cache-dir" should be honored. Consolidate discoveryCacheDir with httpCacheDir so that server resources and http-cache data are stored in the same location, provided via config flags.

func (*CachedDiscoveryClient) Fresh Uses

func (d *CachedDiscoveryClient) Fresh() bool

func (*CachedDiscoveryClient) Invalidate Uses

func (d *CachedDiscoveryClient) Invalidate()

func (*CachedDiscoveryClient) OpenAPISchema Uses

func (d *CachedDiscoveryClient) OpenAPISchema() (*openapi_v2.Document, error)

func (*CachedDiscoveryClient) RESTClient Uses

func (d *CachedDiscoveryClient) RESTClient() restclient.Interface

func (*CachedDiscoveryClient) ServerGroups Uses

func (d *CachedDiscoveryClient) ServerGroups() (*metav1.APIGroupList, error)

func (*CachedDiscoveryClient) ServerPreferredNamespacedResources Uses

func (d *CachedDiscoveryClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error)

func (*CachedDiscoveryClient) ServerPreferredResources Uses

func (d *CachedDiscoveryClient) ServerPreferredResources() ([]*metav1.APIResourceList, error)

func (*CachedDiscoveryClient) ServerResources Uses

func (d *CachedDiscoveryClient) ServerResources() ([]*metav1.APIResourceList, error)

ServerResources returns the supported resources for all groups and versions.

func (*CachedDiscoveryClient) ServerResourcesForGroupVersion Uses

func (d *CachedDiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error)

ServerResourcesForGroupVersion returns the supported resources for a group and version.

func (*CachedDiscoveryClient) ServerVersion Uses

func (d *CachedDiscoveryClient) ServerVersion() (*version.Info, error)

type CachedDiscoveryInterface Uses

type CachedDiscoveryInterface interface {
    DiscoveryInterface
    // Fresh is supposed to tell the caller whether or not to retry if the cache
    // fails to find something (false = retry, true = no need to retry).
    //
    // TODO: this needs to be revisited, this interface can't be locked properly
    // and doesn't make a lot of sense.
    Fresh() bool
    // Invalidate enforces that no cached data is used in the future that is older than the current time.
    Invalidate()
}

CachedDiscoveryInterface is a DiscoveryInterface with cache invalidation and freshness.

type DiscoveryClient Uses

type DiscoveryClient struct {
    LegacyPrefix string
    // contains filtered or unexported fields
}

DiscoveryClient implements the functions that discover server-supported API groups, versions and resources.

func NewDiscoveryClient Uses

func NewDiscoveryClient(c restclient.Interface) *DiscoveryClient

NewDiscoveryClient returns a new DiscoveryClient for the given RESTClient.

func NewDiscoveryClientForConfig Uses

func NewDiscoveryClientForConfig(c *restclient.Config) (*DiscoveryClient, error)

NewDiscoveryClientForConfig creates a new DiscoveryClient for the given config. This client can be used to discover supported resources in the API server.

func NewDiscoveryClientForConfigOrDie Uses

func NewDiscoveryClientForConfigOrDie(c *restclient.Config) *DiscoveryClient

NewDiscoveryClientForConfigOrDie creates a new DiscoveryClient for the given config. If there is an error, it panics.

func (*DiscoveryClient) OpenAPISchema Uses

func (d *DiscoveryClient) OpenAPISchema() (*openapi_v2.Document, error)

OpenAPISchema fetches the open api schema using a rest client and parses the proto.

func (*DiscoveryClient) RESTClient Uses

func (c *DiscoveryClient) RESTClient() restclient.Interface

RESTClient returns a RESTClient that is used to communicate with API server by this client implementation.

func (*DiscoveryClient) ServerGroups Uses

func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err error)

ServerGroups returns the supported groups, with information like supported versions and the preferred version.

func (*DiscoveryClient) ServerPreferredNamespacedResources Uses

func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error)

ServerPreferredNamespacedResources returns the supported namespaced resources with the version preferred by the server.

func (*DiscoveryClient) ServerPreferredResources Uses

func (d *DiscoveryClient) ServerPreferredResources() ([]*metav1.APIResourceList, error)

ServerPreferredResources returns the supported resources with the version preferred by the server.

func (*DiscoveryClient) ServerResources Uses

func (d *DiscoveryClient) ServerResources() ([]*metav1.APIResourceList, error)

ServerResources returns the supported resources for all groups and versions.

func (*DiscoveryClient) ServerResourcesForGroupVersion Uses

func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (resources *metav1.APIResourceList, err error)

ServerResourcesForGroupVersion returns the supported resources for a group and version.

func (*DiscoveryClient) ServerVersion Uses

func (d *DiscoveryClient) ServerVersion() (*version.Info, error)

ServerVersion retrieves and parses the server's version (git version).

type DiscoveryInterface Uses

type DiscoveryInterface interface {
    RESTClient() restclient.Interface
    ServerGroupsInterface
    ServerResourcesInterface
    ServerVersionInterface
    OpenAPISchemaInterface
}

DiscoveryInterface holds the methods that discover server-supported API groups, versions and resources.

type ErrGroupDiscoveryFailed Uses

type ErrGroupDiscoveryFailed struct {
    // Groups is a list of the groups that failed to load and the error cause
    Groups map[schema.GroupVersion]error
}

ErrGroupDiscoveryFailed is returned if one or more API groups fail to load.

func (*ErrGroupDiscoveryFailed) Error Uses

func (e *ErrGroupDiscoveryFailed) Error() string

Error implements the error interface

type OpenAPISchemaInterface Uses

type OpenAPISchemaInterface interface {
    // OpenAPISchema retrieves and parses the swagger API schema the server supports.
    OpenAPISchema() (*openapi_v2.Document, error)
}

OpenAPISchemaInterface has a method to retrieve the open API schema.

type ResourcePredicate Uses

type ResourcePredicate interface {
    Match(groupVersion string, r *metav1.APIResource) bool
}

type ResourcePredicateFunc Uses

type ResourcePredicateFunc func(groupVersion string, r *metav1.APIResource) bool

func (ResourcePredicateFunc) Match Uses

func (fn ResourcePredicateFunc) Match(groupVersion string, r *metav1.APIResource) bool

type ServerGroupsInterface Uses

type ServerGroupsInterface interface {
    // ServerGroups returns the supported groups, with information like supported versions and the
    // preferred version.
    ServerGroups() (*metav1.APIGroupList, error)
}

ServerGroupsInterface has methods for obtaining supported groups on the API server

type ServerResourcesInterface Uses

type ServerResourcesInterface interface {
    // ServerResourcesForGroupVersion returns the supported resources for a group and version.
    ServerResourcesForGroupVersion(groupVersion string) (*metav1.APIResourceList, error)
    // ServerResources returns the supported resources for all groups and versions.
    ServerResources() ([]*metav1.APIResourceList, error)
    // ServerPreferredResources returns the supported resources with the version preferred by the
    // server.
    ServerPreferredResources() ([]*metav1.APIResourceList, error)
    // ServerPreferredNamespacedResources returns the supported namespaced resources with the
    // version preferred by the server.
    ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error)
}

ServerResourcesInterface has methods for obtaining supported resources on the API server

type ServerVersionInterface Uses

type ServerVersionInterface interface {
    // ServerVersion retrieves and parses the server's version (git version).
    ServerVersion() (*version.Info, error)
}

ServerVersionInterface has a method for retrieving the server's version.

type SupportsAllVerbs Uses

type SupportsAllVerbs struct {
    Verbs []string
}

SupportsAllVerbs is a predicate matching a resource iff all given verbs are supported.

func (SupportsAllVerbs) Match Uses

func (p SupportsAllVerbs) Match(groupVersion string, r *metav1.APIResource) bool

type UnstructuredObjectTyper Uses

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

UnstructuredObjectTyper provides a runtime.ObjectTyper implementation for runtime.Unstructured object based on discovery information.

func NewUnstructuredObjectTyper Uses

func NewUnstructuredObjectTyper(typers ...runtime.ObjectTyper) *UnstructuredObjectTyper

NewUnstructuredObjectTyper returns a runtime.ObjectTyper for unstructured objects based on discovery information. It accepts a list of fallback typers for handling objects that are not runtime.Unstructured. It does not delegate the Recognizes check, only ObjectKinds. TODO this only works for the apiextensions server and doesn't recognize any types. Move to point of use.

func (*UnstructuredObjectTyper) ObjectKinds Uses

func (d *UnstructuredObjectTyper) ObjectKinds(obj runtime.Object) (gvks []schema.GroupVersionKind, unversionedType bool, err error)

ObjectKinds returns a slice of one element with the group,version,kind of the provided object, or an error if the object is not runtime.Unstructured or has no group,version,kind information. unversionedType will always be false because runtime.Unstructured object should always have group,version,kind information set.

func (*UnstructuredObjectTyper) Recognizes Uses

func (d *UnstructuredObjectTyper) Recognizes(gvk schema.GroupVersionKind) bool

Recognizes returns true if the provided group,version,kind was in the discovery information.

Directories

PathSynopsis
cached
fake

Package discovery imports 29 packages (graph) and is imported by 484 packages. Updated 2018-05-20. Refresh now. Tools for package owners.