mirror of
https://github.com/kubernetes/client-go.git
synced 2025-06-22 13:17:07 +00:00
Export DefaultServerUrlFor utility function
Signed-off-by: Timo Furrer <tuxtimo@gmail.com> Kubernetes-commit: ebaf49dbd709a94e0c44aa75b4c32b50898a05e3
This commit is contained in:
parent
aa1fae7565
commit
d11d5308d6
@ -316,7 +316,7 @@ func RESTClientFor(config *Config) (*RESTClient, error) {
|
|||||||
|
|
||||||
// Validate config.Host before constructing the transport/client so we can fail fast.
|
// Validate config.Host before constructing the transport/client so we can fail fast.
|
||||||
// ServerURL will be obtained later in RESTClientForConfigAndClient()
|
// ServerURL will be obtained later in RESTClientForConfigAndClient()
|
||||||
_, _, err := defaultServerUrlFor(config)
|
_, _, err := DefaultServerUrlFor(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -343,7 +343,7 @@ func RESTClientForConfigAndClient(config *Config, httpClient *http.Client) (*RES
|
|||||||
return nil, fmt.Errorf("NegotiatedSerializer is required when initializing a RESTClient")
|
return nil, fmt.Errorf("NegotiatedSerializer is required when initializing a RESTClient")
|
||||||
}
|
}
|
||||||
|
|
||||||
baseURL, versionedAPIPath, err := defaultServerUrlFor(config)
|
baseURL, versionedAPIPath, err := DefaultServerUrlFor(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -390,7 +390,7 @@ func UnversionedRESTClientFor(config *Config) (*RESTClient, error) {
|
|||||||
|
|
||||||
// Validate config.Host before constructing the transport/client so we can fail fast.
|
// Validate config.Host before constructing the transport/client so we can fail fast.
|
||||||
// ServerURL will be obtained later in UnversionedRESTClientForConfigAndClient()
|
// ServerURL will be obtained later in UnversionedRESTClientForConfigAndClient()
|
||||||
_, _, err := defaultServerUrlFor(config)
|
_, _, err := DefaultServerUrlFor(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -410,7 +410,7 @@ func UnversionedRESTClientForConfigAndClient(config *Config, httpClient *http.Cl
|
|||||||
return nil, fmt.Errorf("NegotiatedSerializer is required when initializing a RESTClient")
|
return nil, fmt.Errorf("NegotiatedSerializer is required when initializing a RESTClient")
|
||||||
}
|
}
|
||||||
|
|
||||||
baseURL, versionedAPIPath, err := defaultServerUrlFor(config)
|
baseURL, versionedAPIPath, err := DefaultServerUrlFor(config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -548,7 +548,7 @@ func InClusterConfig() (*Config, error) {
|
|||||||
// Note: the Insecure flag is ignored when testing for this value, so MITM attacks are
|
// Note: the Insecure flag is ignored when testing for this value, so MITM attacks are
|
||||||
// still possible.
|
// still possible.
|
||||||
func IsConfigTransportTLS(config Config) bool {
|
func IsConfigTransportTLS(config Config) bool {
|
||||||
baseURL, _, err := defaultServerUrlFor(&config)
|
baseURL, _, err := DefaultServerUrlFor(&config)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -77,9 +77,9 @@ func DefaultVersionedAPIPath(apiPath string, groupVersion schema.GroupVersion) s
|
|||||||
return versionedAPIPath
|
return versionedAPIPath
|
||||||
}
|
}
|
||||||
|
|
||||||
// defaultServerUrlFor is shared between IsConfigTransportTLS and RESTClientFor. It
|
// DefaultServerUrlFor is shared between IsConfigTransportTLS and RESTClientFor. It
|
||||||
// requires Host and Version to be set prior to being called.
|
// requires Host and Version to be set prior to being called.
|
||||||
func defaultServerUrlFor(config *Config) (*url.URL, string, error) {
|
func DefaultServerUrlFor(config *Config) (*url.URL, string, error) {
|
||||||
// TODO: move the default to secure when the apiserver supports TLS by default
|
// TODO: move the default to secure when the apiserver supports TLS by default
|
||||||
// config.Insecure is taken to mean "I want HTTPS but don't bother checking the certs against a CA."
|
// config.Insecure is taken to mean "I want HTTPS but don't bother checking the certs against a CA."
|
||||||
hasCA := len(config.CAFile) != 0 || len(config.CAData) != 0
|
hasCA := len(config.CAFile) != 0 || len(config.CAData) != 0
|
||||||
|
Loading…
Reference in New Issue
Block a user