mirror of
https://github.com/kubernetes/client-go.git
synced 2025-08-10 03:37:19 +00:00
NewDiscoveryClientForConfigAndClient constructor
Kubernetes-commit: f519ab25ab0e7dd8eb4fd72da53daecb9e48211e
This commit is contained in:
parent
fd09dceb88
commit
bb294ffaf0
@ -20,6 +20,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"net/url"
|
"net/url"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
@ -482,12 +483,29 @@ func setDiscoveryDefaults(config *restclient.Config) error {
|
|||||||
|
|
||||||
// NewDiscoveryClientForConfig creates a new DiscoveryClient for the given config. This client
|
// NewDiscoveryClientForConfig creates a new DiscoveryClient for the given config. This client
|
||||||
// can be used to discover supported resources in the API server.
|
// 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) {
|
func NewDiscoveryClientForConfig(c *restclient.Config) (*DiscoveryClient, error) {
|
||||||
config := *c
|
config := *c
|
||||||
if err := setDiscoveryDefaults(&config); err != nil {
|
if err := setDiscoveryDefaults(&config); err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
client, err := restclient.UnversionedRESTClientFor(&config)
|
httpClient, err := restclient.HTTPClientFor(&config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return NewDiscoveryClientForConfigAndClient(&config, httpClient)
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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) {
|
||||||
|
config := *c
|
||||||
|
if err := setDiscoveryDefaults(&config); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
client, err := restclient.UnversionedRESTClientForConfigAndClient(&config, httpClient)
|
||||||
return &DiscoveryClient{restClient: client, LegacyPrefix: "/api"}, err
|
return &DiscoveryClient{restClient: client, LegacyPrefix: "/api"}, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user