Documentation
¶
Overview ¶
Package discovery provides ways to discover server-supported API groups, versions and resources.
Index ¶
- Constants
- func ContentTypeIsGVK(contentType string, gvk schema.GroupVersionKind) (bool, error)
- func FilteredBy(pred ResourcePredicate, rls []*metav1.APIResourceList) []*metav1.APIResourceList
- func GroupDiscoveryFailedErrorGroups(err error) (map[schema.GroupVersion]error, bool)
- func GroupVersionResources(rls []*metav1.APIResourceList) (map[schema.GroupVersionResource]struct{}, error)
- func IsGroupDiscoveryFailedError(err error) bool
- func IsResourceEnabled(client DiscoveryInterface, resourceToCheck schema.GroupVersionResource) (bool, error)
- func MatchesServerVersion(clientVersion apimachineryversion.Info, client DiscoveryInterface) error
- func ServerGroupsAndResources(d DiscoveryInterface) ([]*metav1.APIGroup, []*metav1.APIResourceList, error)
- func ServerGroupsAndResourcesWithContext(ctx context.Context, d DiscoveryInterfaceWithContext) ([]*metav1.APIGroup, []*metav1.APIResourceList, error)
- func ServerPreferredNamespacedResources(d DiscoveryInterface) ([]*metav1.APIResourceList, error)
- func ServerPreferredNamespacedResourcesWithContext(ctx context.Context, d DiscoveryInterfaceWithContext) ([]*metav1.APIResourceList, error)
- func ServerPreferredResources(d DiscoveryInterface) ([]*metav1.APIResourceList, error)
- func ServerPreferredResourcesWithContext(ctx context.Context, d DiscoveryInterfaceWithContext) ([]*metav1.APIResourceList, error)
- func ServerSupportsVersion(client DiscoveryInterface, requiredGV schema.GroupVersion) error
- func SplitGroupsAndResources(aggregatedGroups apidiscovery.APIGroupDiscoveryList) (*metav1.APIGroupList, map[schema.GroupVersion]*metav1.APIResourceList, ...)
- func ToOpenAPIClientWithContext(i openapi.Client) openapi.ClientWithContext
- type AggregatedDiscoveryInterface
- type AggregatedDiscoveryInterfaceWithContext
- type CachedDiscoveryInterface
- type CachedDiscoveryInterfaceWithContext
- type DiscoveryClient
- func NewDiscoveryClient(c restclient.Interface) *DiscoveryClient
- func NewDiscoveryClientForConfig(c *restclient.Config) (*DiscoveryClient, error)
- func NewDiscoveryClientForConfigAndClient(c *restclient.Config, httpClient *http.Client) (*DiscoveryClient, error)
- func NewDiscoveryClientForConfigOrDie(c *restclient.Config) *DiscoveryClient
- func (d *DiscoveryClient) GroupsAndMaybeResources() (*metav1.APIGroupList, map[schema.GroupVersion]*metav1.APIResourceList, ...)
- func (d *DiscoveryClient) GroupsAndMaybeResourcesWithContext(ctx context.Context) (*metav1.APIGroupList, map[schema.GroupVersion]*metav1.APIResourceList, ...)
- func (d *DiscoveryClient) OpenAPISchema() (*openapi_v2.Document, error)
- func (d *DiscoveryClient) OpenAPISchemaWithContext(ctx context.Context) (*openapi_v2.Document, error)
- func (d *DiscoveryClient) OpenAPIV3() openapi.Client
- func (d *DiscoveryClient) OpenAPIV3WithContext(ctx context.Context) openapi.ClientWithContext
- func (d *DiscoveryClient) RESTClient() restclient.Interface
- func (d *DiscoveryClient) ServerGroups() (*metav1.APIGroupList, error)
- func (d *DiscoveryClient) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error)
- func (d *DiscoveryClient) ServerGroupsAndResourcesWithContext(ctx context.Context) ([]*metav1.APIGroup, []*metav1.APIResourceList, error)
- func (d *DiscoveryClient) ServerGroupsWithContext(ctx context.Context) (*metav1.APIGroupList, error)
- func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error)
- func (d *DiscoveryClient) ServerPreferredNamespacedResourcesWithContext(ctx context.Context) ([]*metav1.APIResourceList, error)
- func (d *DiscoveryClient) ServerPreferredResources() ([]*metav1.APIResourceList, error)
- func (d *DiscoveryClient) ServerPreferredResourcesWithContext(ctx context.Context) ([]*metav1.APIResourceList, error)
- func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (resources *metav1.APIResourceList, err error)
- func (d *DiscoveryClient) ServerResourcesForGroupVersionWithContext(ctx context.Context, groupVersion string) (resources *metav1.APIResourceList, err error)
- func (d *DiscoveryClient) ServerVersion() (*version.Info, error)
- func (d *DiscoveryClient) ServerVersionWithContext(ctx context.Context) (*version.Info, error)
- func (d *DiscoveryClient) WithLegacy() DiscoveryInterface
- func (d *DiscoveryClient) WithLegacyWithContext(ctx context.Context) DiscoveryInterfaceWithContext
- type DiscoveryInterface
- type DiscoveryInterfaceWithContext
- type DiscoveryInterfaces
- type ErrGroupDiscoveryFailed
- type OpenAPISchemaInterface
- type OpenAPISchemaInterfaceWithContext
- type OpenAPIV3SchemaInterface
- type OpenAPIV3SchemaInterfaceWithContext
- type ResourcePredicate
- type ResourcePredicateFunc
- type ServerGroupsInterface
- type ServerGroupsInterfaceWithContext
- type ServerResourcesInterface
- type ServerResourcesInterfaceWithContext
- type ServerVersionInterface
- type ServerVersionInterfaceWithContext
- type StaleGroupVersionError
- type SupportsAllVerbs
Constants ¶
const ( AcceptV1 = runtime.ContentTypeJSON // Aggregated discovery content-type. NOTE: content-type parameters // MUST be ordered (g, v, as) for server in "Accept" header (BUT we are resilient // to ordering when comparing returned values in "Content-Type" header). AcceptV2 = runtime.ContentTypeJSON + ";" + "g=apidiscovery.k8s.io;v=v2;as=APIGroupDiscoveryList" AcceptV2NoPeer = runtime.ContentTypeJSON + ";" + "g=apidiscovery.k8s.io;v=v2;as=APIGroupDiscoveryList;profile=nopeer" )
Variables ¶
This section is empty.
Functions ¶
func ContentTypeIsGVK ¶ added in v0.27.6
func ContentTypeIsGVK(contentType string, gvk schema.GroupVersionKind) (bool, error)
ContentTypeIsGVK checks of the content-type string is both "application/json" and matches the provided GVK. An error is returned if the content type string is malformed. NOTE: This function is resilient to the ordering of the content-type parameters, as well as parameters added by intermediaries such as proxies or gateways. Examples:
("application/json; g=apidiscovery.k8s.io;v=v2;as=APIGroupDiscoveryList", {apidiscovery.k8s.io, v2, APIGroupDiscoveryList}) = (true, nil)
("application/json; as=APIGroupDiscoveryList;v=v2;g=apidiscovery.k8s.io", {apidiscovery.k8s.io, v2, APIGroupDiscoveryList}) = (true, nil)
("application/json; as=APIGroupDiscoveryList;v=v2;g=apidiscovery.k8s.io;charset=utf-8", {apidiscovery.k8s.io, v2, APIGroupDiscoveryList}) = (true, nil)
("application/json", any GVK) = (false, nil)
("application/json; charset=UTF-8", any GVK) = (false, nil)
("malformed content type string", any GVK) = (false, error)
func FilteredBy ¶
func FilteredBy(pred ResourcePredicate, rls []*metav1.APIResourceList) []*metav1.APIResourceList
FilteredBy filters by the given predicate. Empty APIResourceLists are dropped.
func GroupDiscoveryFailedErrorGroups ¶ added in v0.29.0
func GroupDiscoveryFailedErrorGroups(err error) (map[schema.GroupVersion]error, bool)
GroupDiscoveryFailedErrorGroups returns true if the error is an ErrGroupDiscoveryFailed error, along with the map of group versions that failed discovery.
func GroupVersionResources ¶
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 IsResourceEnabled ¶ added in v0.24.0
func IsResourceEnabled(client DiscoveryInterface, resourceToCheck schema.GroupVersionResource) (bool, error)
IsResourceEnabled queries the server to determine if the resource specified is present on the server. This is particularly helpful when writing a controller or an e2e test that requires a particular resource to function.
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 ServerGroupsAndResources ¶
func ServerGroupsAndResources(d DiscoveryInterface) ([]*metav1.APIGroup, []*metav1.APIResourceList, error)
ServerGroupsAndResourcesWithContext is a better alternative because it supports contextual logging and cancellation.
Contextual logging: Use ServerGroupsAndResourcesWithContext instead.
func ServerGroupsAndResourcesWithContext ¶ added in v0.37.0
func ServerGroupsAndResourcesWithContext(ctx context.Context, d DiscoveryInterfaceWithContext) ([]*metav1.APIGroup, []*metav1.APIResourceList, error)
func ServerPreferredNamespacedResources ¶
func ServerPreferredNamespacedResources(d DiscoveryInterface) ([]*metav1.APIResourceList, error)
ServerPreferredNamespacedResources uses the provided discovery interface to look up preferred namespaced resources
ServerPreferredNamespacedResourcesWithContext is a better alternative because it supports contextual logging and cancellation.
Contextual logging: Use ServerPreferredNamespacedResourcesWithContext instead.