import "k8s.io/client-go/discovery"
Package discovery provides ways to discover server-supported API groups, versions and resources.
discovery_client.go doc.go helper.go
func FilteredBy(pred ResourcePredicate, rls []*metav1.APIResourceList) []*metav1.APIResourceList
FilteredBy filters by the given predicate. Empty APIResourceLists are dropped.
func GroupVersionResources(rls []*metav1.APIResourceList) (map[schema.GroupVersionResource]struct{}, error)
GroupVersionResources converts APIResourceLists to the GroupVersionResources.
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(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 ServerGroupsAndResources(d DiscoveryInterface) ([]*metav1.APIGroup, []*metav1.APIResourceList, error)
func ServerPreferredNamespacedResources(d DiscoveryInterface) ([]*metav1.APIResourceList, error)
ServerPreferredNamespacedResources uses the provided discovery interface to look up preferred namespaced resources
func ServerPreferredResources(d DiscoveryInterface) ([]*metav1.APIResourceList, error)
ServerPreferredResources uses the provided discovery interface to look up preferred resources
func ServerResources(d DiscoveryInterface) ([]*metav1.APIResourceList, error)
ServerResources uses the provided discovery interface to look up supported resources for all groups and versions. Deprecated: use ServerGroupsAndResources instead.
func ServerSupportsVersion(client DiscoveryInterface, requiredGV schema.GroupVersion) error
ServerSupportsVersion returns an error if the server doesn't have the required version
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 that is older than the current time // is used. Invalidate() }
CachedDiscoveryInterface is a DiscoveryInterface with cache invalidation and freshness. Note that If the ServerResourcesForGroupVersion method returns a cache miss error, the user needs to explicitly call Invalidate to clear the cache, otherwise the same cache miss error will be returned next time.
DiscoveryClient implements the functions that discover server-supported API groups, versions and resources.
func NewDiscoveryClient(c restclient.Interface) *DiscoveryClient
NewDiscoveryClient returns a new DiscoveryClient for the given RESTClient.
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(c *restclient.Config) *DiscoveryClient
NewDiscoveryClientForConfigOrDie creates a new DiscoveryClient for the given config. If there is an error, it panics.
func (d *DiscoveryClient) OpenAPISchema() (*openapi_v2.Document, error)
OpenAPISchema fetches the open api schema using a rest client and parses the proto.
func (d *DiscoveryClient) RESTClient() restclient.Interface
RESTClient returns a RESTClient that is used to communicate with API server by this client implementation.
func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err error)
ServerGroups returns the supported groups, with information like supported versions and the preferred version.
func (d *DiscoveryClient) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error)
ServerGroupsAndResources returns the supported resources for all groups and versions.
func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error)
ServerPreferredNamespacedResources returns the supported namespaced resources with the version preferred by the server.
func (d *DiscoveryClient) ServerPreferredResources() ([]*metav1.APIResourceList, error)
ServerPreferredResources returns the supported resources with the version preferred by the server.
func (d *DiscoveryClient) ServerResources() ([]*metav1.APIResourceList, error)
ServerResources returns the supported resources for all groups and versions. Deprecated: use ServerGroupsAndResources instead.
func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (resources *metav1.APIResourceList, err error)
ServerResourcesForGroupVersion returns the supported resources for a group and version.
func (d *DiscoveryClient) ServerVersion() (*version.Info, error)
ServerVersion retrieves and parses the server's version (git version).
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 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 (e *ErrGroupDiscoveryFailed) Error() string
Error implements the error interface
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 interface { Match(groupVersion string, r *metav1.APIResource) bool }
ResourcePredicate has a method to check if a resource matches a given condition.
type ResourcePredicateFunc func(groupVersion string, r *metav1.APIResource) bool
ResourcePredicateFunc returns true if it matches a resource based on a custom condition.
func (fn ResourcePredicateFunc) Match(groupVersion string, r *metav1.APIResource) bool
Match is a wrapper around ResourcePredicateFunc.
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 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. // // The returned resource list might be non-nil with partial results even in the case of // non-nil error. // // Deprecated: use ServerGroupsAndResources instead. ServerResources() ([]*metav1.APIResourceList, error) // ServerResources returns the supported groups and resources for all groups and versions. // // The returned group and resource lists might be non-nil with partial results even in the // case of non-nil error. ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error) // ServerPreferredResources returns the supported resources with the version preferred by the // server. // // The returned group and resource lists might be non-nil with partial results even in the // case of non-nil error. ServerPreferredResources() ([]*metav1.APIResourceList, error) // ServerPreferredNamespacedResources returns the supported namespaced resources with the // version preferred by the server. // // The returned resource list might be non-nil with partial results even in the case of // non-nil error. ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) }
ServerResourcesInterface has methods for obtaining supported resources on the API server
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.
SupportsAllVerbs is a predicate matching a resource iff all given verbs are supported.
func (p SupportsAllVerbs) Match(groupVersion string, r *metav1.APIResource) bool
Match checks if a resource contains all the given verbs.
Path | Synopsis |
---|---|
cached | |
cached/disk | |
cached/memory | |
fake |
Package discovery imports 19 packages (graph) and is imported by 1424 packages. Updated 2019-12-13. Refresh now. Tools for package owners.