const defaultRetries … const openAPIV2mimePb … const defaultTimeout … const defaultBurst … const AcceptV1 … const AcceptV2Beta1 … const AcceptV2 … const acceptDiscoveryFormats … var v2Beta1GVK … var v2GVK … type DiscoveryInterface … type AggregatedDiscoveryInterface … type CachedDiscoveryInterface … type ServerGroupsInterface … type ServerResourcesInterface … type ServerVersionInterface … type OpenAPISchemaInterface … type OpenAPIV3SchemaInterface … type DiscoveryClient … var _ … // Convert metav1.APIVersions to metav1.APIGroup. APIVersions is used by legacy v1, so // group would be "". func apiVersionsToAPIGroup(apiVersions *metav1.APIVersions) (apiGroup metav1.APIGroup) { … } // GroupsAndMaybeResources returns the discovery groups, and (if new aggregated // discovery format) the resources keyed by group/version. Merges discovery groups // and resources from /api and /apis (either aggregated or not). Legacy groups // must be ordered first. The server will either return both endpoints (/api, /apis) // as aggregated discovery format or legacy format. For safety, resources will only // be returned if both endpoints returned resources. Returned "failedGVs" can be // empty, but will only be nil in the case an error is returned. func (d *DiscoveryClient) GroupsAndMaybeResources() ( *metav1.APIGroupList, map[schema.GroupVersion]*metav1.APIResourceList, map[schema.GroupVersion]error, error) { … } // downloadLegacy returns the discovery groups and possibly resources // for the legacy v1 GVR at /api, or an error if one occurred. It is // possible for the resource map to be nil if the server returned // the unaggregated discovery. Returned "failedGVs" can be empty, but // will only be nil in the case of a returned error. func (d *DiscoveryClient) downloadLegacy() ( *metav1.APIGroupList, map[schema.GroupVersion]*metav1.APIResourceList, map[schema.GroupVersion]error, error) { … } // downloadAPIs returns the discovery groups and (if aggregated format) the // discovery resources. The returned groups will always exist, but the // resources map may be nil. Returned "failedGVs" can be empty, but will // only be nil in the case of a returned error. func (d *DiscoveryClient) downloadAPIs() ( *metav1.APIGroupList, map[schema.GroupVersion]*metav1.APIResourceList, map[schema.GroupVersion]error, 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=v2beta1;as=APIGroupDiscoveryList", {apidiscovery.k8s.io, v2beta1, APIGroupDiscoveryList}) = (true, nil) // ("application/json; as=APIGroupDiscoveryList;v=v2beta1;g=apidiscovery.k8s.io", {apidiscovery.k8s.io, v2beta1, APIGroupDiscoveryList}) = (true, nil) // ("application/json; as=APIGroupDiscoveryList;v=v2beta1;g=apidiscovery.k8s.io;charset=utf-8", {apidiscovery.k8s.io, v2beta1, 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 ContentTypeIsGVK(contentType string, gvk schema.GroupVersionKind) (bool, error) { … } // ServerGroups returns the supported groups, with information like supported versions and the // preferred version. func (d *DiscoveryClient) ServerGroups() (*metav1.APIGroupList, error) { … } // ServerResourcesForGroupVersion returns the supported resources for a group and version. func (d *DiscoveryClient) ServerResourcesForGroupVersion(groupVersion string) (resources *metav1.APIResourceList, err error) { … } // ServerGroupsAndResources returns the supported resources for all groups and versions. func (d *DiscoveryClient) ServerGroupsAndResources() ([]*metav1.APIGroup, []*metav1.APIResourceList, error) { … } type ErrGroupDiscoveryFailed … // Error implements the error interface func (e *ErrGroupDiscoveryFailed) Error() string { … } // Is makes it possible for the callers to use `errors.Is(` helper on errors wrapped with ErrGroupDiscoveryFailed error. func (e *ErrGroupDiscoveryFailed) Is(target 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 IsGroupDiscoveryFailedError(err error) bool { … } // GroupDiscoveryFailedErrorGroups returns true if the error is an ErrGroupDiscoveryFailed error, // along with the map of group versions that failed discovery. func GroupDiscoveryFailedErrorGroups(err error) (map[schema.GroupVersion]error, bool) { … } func ServerGroupsAndResources(d DiscoveryInterface) ([]*metav1.APIGroup, []*metav1.APIResourceList, error) { … } // ServerPreferredResources uses the provided discovery interface to look up preferred resources func ServerPreferredResources(d DiscoveryInterface) ([]*metav1.APIResourceList, error) { … } // fetchServerResourcesForGroupVersions uses the discovery client to fetch the resources for the specified groups in parallel. func fetchGroupVersionResources(d DiscoveryInterface, apiGroups *metav1.APIGroupList) (map[schema.GroupVersion]*metav1.APIResourceList, map[schema.GroupVersion]error) { … } // ServerPreferredResources returns the supported resources with the version preferred by the // server. func (d *DiscoveryClient) ServerPreferredResources() ([]*metav1.APIResourceList, error) { … } // ServerPreferredNamespacedResources returns the supported namespaced resources with the // version preferred by the server. func (d *DiscoveryClient) ServerPreferredNamespacedResources() ([]*metav1.APIResourceList, error) { … } // ServerPreferredNamespacedResources uses the provided discovery interface to look up preferred namespaced resources func ServerPreferredNamespacedResources(d DiscoveryInterface) ([]*metav1.APIResourceList, error) { … } // ServerVersion retrieves and parses the server's version (git version). func (d *DiscoveryClient) ServerVersion() (*version.Info, error) { … } // OpenAPISchema fetches the open api v2 schema using a rest client and parses the proto. func (d *DiscoveryClient) OpenAPISchema() (*openapi_v2.Document, error) { … } func (d *DiscoveryClient) OpenAPIV3() openapi.Client { … } // WithLegacy returns copy of current discovery client that will only // receive the legacy discovery format. func (d *DiscoveryClient) WithLegacy() DiscoveryInterface { … } // withRetries retries the given recovery function in case the groups supported by the server change after ServerGroup() returns. func withRetries(maxRetries int, f func() ([]*metav1.APIGroup, []*metav1.APIResourceList, error)) ([]*metav1.APIGroup, []*metav1.APIResourceList, error) { … } func setDiscoveryDefaults(config *restclient.Config) error { … } // NewDiscoveryClientForConfig creates a new DiscoveryClient for the given config. This client // can be used to discover supported resources in the API server. // NewDiscoveryClientForConfig is equivalent to NewDiscoveryClientForConfigAndClient(c, httpClient), // where httpClient was generated with rest.HTTPClientFor(c). func NewDiscoveryClientForConfig(c *restclient.Config) (*DiscoveryClient, error) { … } // NewDiscoveryClientForConfigAndClient creates a new DiscoveryClient for the given config. This client // can be used to discover supported resources in the API server. // Note the http client provided takes precedence over the configured transport values. func NewDiscoveryClientForConfigAndClient(c *restclient.Config, httpClient *http.Client) (*DiscoveryClient, error) { … } // NewDiscoveryClientForConfigOrDie creates a new DiscoveryClient for the given config. If // there is an error, it panics. func NewDiscoveryClientForConfigOrDie(c *restclient.Config) *DiscoveryClient { … } // NewDiscoveryClient returns a new DiscoveryClient for the given RESTClient. func NewDiscoveryClient(c restclient.Interface) *DiscoveryClient { … } // RESTClient returns a RESTClient that is used to communicate // with API server by this client implementation. func (d *DiscoveryClient) RESTClient() restclient.Interface { … }