Documentation ¶
Index ¶
- func FilteredBy(pred ResourcePredicate, rls []*metav1.APIResourceList) []*metav1.APIResourceList
- func GroupVersionResources(rls []*metav1.APIResourceList) (map[schema.GroupVersionResource]struct{}, error)
- func IsGroupDiscoveryFailedError(err error) bool
- func MatchesServerVersion(clientVersion apimachineryversion.Info, client DiscoveryInterface) error
- func NewRESTMapper(groupResources []*APIGroupResources, ...) meta.RESTMapper
- func ServerSupportsVersion(client DiscoveryInterface, requiredGV schema.GroupVersion) error
- type APIGroupResources
- type CachedDiscoveryInterface
- type DeferredDiscoveryRESTMapper
- func (d *DeferredDiscoveryRESTMapper) KindFor(resource schema.GroupVersionResource) (gvk schema.GroupVersionKind, err error)
- func (d *DeferredDiscoveryRESTMapper) KindsFor(resource schema.GroupVersionResource) (gvks []schema.GroupVersionKind, err error)
- func (d *DeferredDiscoveryRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (m *meta.RESTMapping, err error)
- func (d *DeferredDiscoveryRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) (ms []*meta.RESTMapping, err error)
- func (d *DeferredDiscoveryRESTMapper) Reset()
- func (d *DeferredDiscoveryRESTMapper) ResourceFor(input schema.GroupVersionResource) (gvr schema.GroupVersionResource, err error)
- func (d *DeferredDiscoveryRESTMapper) ResourceSingularizer(resource string) (singular string, err error)
- func (d *DeferredDiscoveryRESTMapper) ResourcesFor(input schema.GroupVersionResource) (gvrs []schema.GroupVersionResource, err error)
- func (d *DeferredDiscoveryRESTMapper) String() string
- type DiscoveryClient
- func (d *DiscoveryClient) OpenAPISchema() (*spec.Swagger, error)
- func (c *DiscoveryClient) RESTClient() restclient.Interface
- func (d *DiscoveryClient) ServerGroups() (apiGroupList *metav1.APIGroupList, err error)
- func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error)
- func (d *DiscoveryClient) ServerPreferredResources() ([]*metav1.APIResourceList, error)
- func (d *DiscoveryClient) ServerResources() ([]*metav1.APIResourceList, error)
- func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (resources *metav1.APIResourceList, err error)
- func (d *DiscoveryClient) ServerVersion() (*version.Info, error)
- func (d *DiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*swagger.ApiDeclaration, error)
- type DiscoveryInterface
- type ErrGroupDiscoveryFailed
- type OpenAPISchemaInterface
- type ResourcePredicate
- type ResourcePredicateFunc
- type ServerGroupsInterface
- type ServerResourcesInterface
- type ServerVersionInterface
- type SupportsAllVerbs
- type SwaggerSchemaInterface
- type UnstructuredObjectTyper
- func (d *UnstructuredObjectTyper) IsUnversioned(obj runtime.Object) (unversioned bool, ok bool)
- func (d *UnstructuredObjectTyper) ObjectKind(obj runtime.Object) (schema.GroupVersionKind, error)
- func (d *UnstructuredObjectTyper) ObjectKinds(obj runtime.Object) (gvks []schema.GroupVersionKind, unversionedType bool, err error)
- func (d *UnstructuredObjectTyper) Recognizes(gvk schema.GroupVersionKind) bool
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func FilteredBy ¶ added in v1.6.0
func FilteredBy(pred ResourcePredicate, rls []*metav1.APIResourceList) []*metav1.APIResourceList
FilteredBy filters by the given predicate. Empty APIResourceLists are dropped.
func GroupVersionResources ¶ added in v1.6.0
func GroupVersionResources(rls []*metav1.APIResourceList) (map[schema.GroupVersionResource]struct{}, error)
GroupVersionResources converts APIResourceLists to the GroupVersionResources.
func IsGroupDiscoveryFailedError ¶
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 ¶
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 NewRESTMapper ¶
func NewRESTMapper(groupResources []*APIGroupResources, versionInterfaces meta.VersionInterfacesFunc) meta.RESTMapper
NewRESTMapper returns a PriorityRESTMapper based on the discovered groups and resources passed in.
func ServerSupportsVersion ¶ added in v1.7.0
func ServerSupportsVersion(client DiscoveryInterface, requiredGV schema.GroupVersion) error
ServerSupportsVersion returns an error if the server doesn't have the required version
Types ¶
type APIGroupResources ¶
type APIGroupResources struct { Group metav1.APIGroup // A mapping of version string to a slice of APIResources for // that version. VersionedResources map[string][]metav1.APIResource }
APIGroupResources is an API group with a mapping of versions to resources.
func GetAPIGroupResources ¶
func GetAPIGroupResources(cl DiscoveryInterface) ([]*APIGroupResources, error)
GetAPIGroupResources uses the provided discovery client to gather discovery information and populate a slice of APIGroupResources.
type CachedDiscoveryInterface ¶
type CachedDiscoveryInterface interface { DiscoveryInterface // Fresh returns true if no cached data was used that had been retrieved before the instantiation. 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 DeferredDiscoveryRESTMapper ¶
type DeferredDiscoveryRESTMapper struct {
// contains filtered or unexported fields
}
DeferredDiscoveryRESTMapper is a RESTMapper that will defer initialization of the RESTMapper until the first mapping is requested.
func NewDeferredDiscoveryRESTMapper ¶
func NewDeferredDiscoveryRESTMapper(cl CachedDiscoveryInterface, versionInterface meta.VersionInterfacesFunc) *DeferredDiscoveryRESTMapper
NewDeferredDiscoveryRESTMapper returns a DeferredDiscoveryRESTMapper that will lazily query the provided client for discovery information to do REST mappings.
func (*DeferredDiscoveryRESTMapper) KindFor ¶
func (d *DeferredDiscoveryRESTMapper) KindFor(resource schema.GroupVersionResource) (gvk schema.GroupVersionKind, err error)
KindFor takes a partial resource and returns back the single match. It returns an error if there are multiple matches.
func (*DeferredDiscoveryRESTMapper) KindsFor ¶
func (d *DeferredDiscoveryRESTMapper) KindsFor(resource schema.GroupVersionResource) (gvks []schema.GroupVersionKind, err error)
KindsFor takes a partial resource and returns back the list of potential kinds in priority order.
func (*DeferredDiscoveryRESTMapper) RESTMapping ¶
func (d *DeferredDiscoveryRESTMapper) RESTMapping(gk schema.GroupKind, versions ...string) (m *meta.RESTMapping, err error)
RESTMapping identifies a preferred resource mapping for the provided group kind.
func (*DeferredDiscoveryRESTMapper) RESTMappings ¶
func (d *DeferredDiscoveryRESTMapper) RESTMappings(gk schema.GroupKind, versions ...string) (ms []*meta.RESTMapping, err error)
RESTMappings returns the RESTMappings for the provided group kind in a rough internal preferred order. If no kind is found, it will return a NoResourceMatchError.
func (*DeferredDiscoveryRESTMapper) Reset ¶
func (d *DeferredDiscoveryRESTMapper) Reset()
Reset resets the internally cached Discovery information and will cause the next mapping request to re-discover.
func (*DeferredDiscoveryRESTMapper) ResourceFor ¶
func (d *DeferredDiscoveryRESTMapper) ResourceFor(input schema.GroupVersionResource) (gvr schema.GroupVersionResource, err error)
ResourceFor takes a partial resource and returns back the single match. It returns an error if there are multiple matches.
func (*DeferredDiscoveryRESTMapper) ResourceSingularizer ¶
func (d *DeferredDiscoveryRESTMapper) ResourceSingularizer(resource string) (singular string, err error)
ResourceSingularizer converts a resource name from plural to singular (e.g., from pods to pod).
func (*DeferredDiscoveryRESTMapper) ResourcesFor ¶
func (d *DeferredDiscoveryRESTMapper) ResourcesFor(input schema.GroupVersionResource) (gvrs []schema.GroupVersionResource, err error)
ResourcesFor takes a partial resource and returns back the list of potential resource in priority order.
func (*DeferredDiscoveryRESTMapper) String ¶
func (d *DeferredDiscoveryRESTMapper) String() string
type DiscoveryClient ¶
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 ¶
func NewDiscoveryClient(c restclient.Interface) *DiscoveryClient
New creates a new DiscoveryClient for the given RESTClient.
func NewDiscoveryClientForConfig ¶
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 ¶
func NewDiscoveryClientForConfigOrDie(c *restclient.Config) *DiscoveryClient
NewDiscoveryClientForConfig creates a new DiscoveryClient for the given config. If there is an error, it panics.
func (*DiscoveryClient) OpenAPISchema ¶ added in v1.7.0
func (d *DiscoveryClient) OpenAPISchema() (*spec.Swagger, error)
OpenAPISchema fetches the open api schema using a rest client and parses the json. Warning: this is very expensive (~1.2s)
func (*DiscoveryClient) RESTClient ¶
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 ¶
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 ¶
func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error)
ServerPreferredNamespacedResources returns the supported namespaced resources with the version preferred by the server.
func (*DiscoveryClient) ServerPreferredResources ¶
func (d *DiscoveryClient) ServerPreferredResources() ([]*metav1.APIResourceList, error)
ServerPreferredResources returns the supported resources with the version preferred by the server.
func (*DiscoveryClient) ServerResources ¶
func (d *DiscoveryClient) ServerResources() ([]*metav1.APIResourceList, error)
ServerResources returns the supported resources for all groups and versions.
func (*DiscoveryClient) ServerResourcesForGroupVersion ¶
func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (resources *metav1.APIResourceList, err error)
ServerResourcesForGroupVersion returns the supported resources for a group and version.
func (*DiscoveryClient) ServerVersion ¶
func (d *DiscoveryClient) ServerVersion() (*version.Info, error)
ServerVersion retrieves and parses the server's version (git version).
func (*DiscoveryClient) SwaggerSchema ¶
func (d *DiscoveryClient) SwaggerSchema(version schema.GroupVersion) (*swagger.ApiDeclaration, error)
SwaggerSchema retrieves and parses the swagger API schema the server supports. TODO: Replace usages with Open API. Tracked in https://github.com/kubernetes/kubernetes/issues/44589
type DiscoveryInterface ¶
type DiscoveryInterface interface { RESTClient() restclient.Interface ServerGroupsInterface ServerResourcesInterface ServerVersionInterface SwaggerSchemaInterface OpenAPISchemaInterface }
DiscoveryInterface holds the methods that discover server-supported API groups, versions and resources.
type ErrGroupDiscoveryFailed ¶
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 ¶
func (e *ErrGroupDiscoveryFailed) Error() string
Error implements the error interface
type OpenAPISchemaInterface ¶ added in v1.7.0
type OpenAPISchemaInterface interface { // OpenAPISchema retrieves and parses the swagger API schema the server supports. OpenAPISchema() (*spec.Swagger, error) }
OpenAPISchemaInterface has a method to retrieve the open API schema.
type ResourcePredicate ¶ added in v1.6.0
type ResourcePredicate interface {
Match(groupVersion string, r *metav1.APIResource) bool
}
type ResourcePredicateFunc ¶ added in v1.6.0
type ResourcePredicateFunc func(groupVersion string, r *metav1.APIResource) bool
func (ResourcePredicateFunc) Match ¶ added in v1.6.0
func (fn ResourcePredicateFunc) Match(groupVersion string, r *metav1.APIResource) bool
type ServerGroupsInterface ¶
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 ¶
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 ¶
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 ¶ added in v1.6.0
type SupportsAllVerbs struct {
Verbs []string
}
SupportsAllVerbs is a predicate matching a resource iff all given verbs are supported.
func (SupportsAllVerbs) Match ¶ added in v1.6.0
func (p SupportsAllVerbs) Match(groupVersion string, r *metav1.APIResource) bool
type SwaggerSchemaInterface ¶
type SwaggerSchemaInterface interface { // SwaggerSchema retrieves and parses the swagger API schema the server supports. SwaggerSchema(version schema.GroupVersion) (*swagger.ApiDeclaration, error) }
SwaggerSchemaInterface has a method to retrieve the swagger schema.
type UnstructuredObjectTyper ¶
type UnstructuredObjectTyper struct {
// contains filtered or unexported fields
}
UnstructuredObjectTyper provides a runtime.ObjectTyper implmentation for runtime.Unstructured object based on discovery information.
func NewUnstructuredObjectTyper ¶
func NewUnstructuredObjectTyper(groupResources []*APIGroupResources) *UnstructuredObjectTyper
NewUnstructuredObjectTyper returns a runtime.ObjectTyper for unstructred objects based on discovery information.
func (*UnstructuredObjectTyper) IsUnversioned ¶
func (d *UnstructuredObjectTyper) IsUnversioned(obj runtime.Object) (unversioned bool, ok bool)
IsUnversioned returns false always because runtime.Unstructured objects should always have group,version,kind information set. ok will be true if the object's group,version,kind is api.Registry.
func (*UnstructuredObjectTyper) ObjectKind ¶
func (d *UnstructuredObjectTyper) ObjectKind(obj runtime.Object) (schema.GroupVersionKind, error)
ObjectKind returns the group,version,kind of the provided object, or an error if the object in not runtime.Unstructured or has no group,version,kind information.
func (*UnstructuredObjectTyper) ObjectKinds ¶
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 ¶
func (d *UnstructuredObjectTyper) Recognizes(gvk schema.GroupVersionKind) bool
Recognizes returns true if the provided group,version,kind was in the discovery information.