mirror of
https://github.com/kubernetes/client-go.git
synced 2025-07-21 02:20:34 +00:00
expose NewForConfigAndClient for the dynamic client
Kubernetes-commit: b584195e5cc0a1094318ba886a9aecd2f675d59c
This commit is contained in:
parent
bb294ffaf0
commit
12956a0d53
@ -19,6 +19,7 @@ package dynamic
|
|||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
"k8s.io/apimachinery/pkg/api/meta"
|
"k8s.io/apimachinery/pkg/api/meta"
|
||||||
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
|
||||||
@ -60,17 +61,30 @@ func NewForConfigOrDie(c *rest.Config) Interface {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// NewForConfig creates a new dynamic client or returns an error.
|
// NewForConfig creates a new dynamic client or returns an error.
|
||||||
|
// NewForConfig is equivalent to NewForConfigAndClient(c, httpClient),
|
||||||
|
// where httpClient was generated with rest.HTTPClientFor(c).
|
||||||
func NewForConfig(inConfig *rest.Config) (Interface, error) {
|
func NewForConfig(inConfig *rest.Config) (Interface, error) {
|
||||||
config := ConfigFor(inConfig)
|
config := ConfigFor(inConfig)
|
||||||
|
|
||||||
|
httpClient, err := rest.HTTPClientFor(config)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return NewForConfigAndClient(config, httpClient)
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewForConfigAndClient creates a new dynamic client for the given config and http client.
|
||||||
|
// Note the http client provided takes precedence over the configured transport values.
|
||||||
|
func NewForConfigAndClient(inConfig *rest.Config, h *http.Client) (Interface, error) {
|
||||||
|
config := ConfigFor(inConfig)
|
||||||
// for serializing the options
|
// for serializing the options
|
||||||
config.GroupVersion = &schema.GroupVersion{}
|
config.GroupVersion = &schema.GroupVersion{}
|
||||||
config.APIPath = "/if-you-see-this-search-for-the-break"
|
config.APIPath = "/if-you-see-this-search-for-the-break"
|
||||||
|
|
||||||
restClient, err := rest.RESTClientFor(config)
|
restClient, err := rest.RESTClientForConfigAndClient(config, h)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
return &dynamicClient{client: restClient}, nil
|
return &dynamicClient{client: restClient}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user