MCPcopy
hub / github.com/kubernetes/client-go / New

Function New

transport/transport.go:30–51  ·  view source on GitHub ↗

New returns an http.RoundTripper that will provide the authentication or transport level security defined by the provided Config.

(config *Config)

Source from the content-addressed store, hash-verified

28// New returns an http.RoundTripper that will provide the authentication
29// or transport level security defined by the provided Config.
30func New(config *Config) (http.RoundTripper, error) {
31 // Set transport level security
32 if config.Transport != nil && (config.HasCA() || config.HasCertAuth() || config.HasCertCallback() || config.TLS.Insecure) {
33 return nil, fmt.Errorf("using a custom transport with TLS certificate options or the insecure flag is not allowed")
34 }
35
36 var (
37 rt http.RoundTripper
38 err error
39 )
40
41 if config.Transport != nil {
42 rt = config.Transport
43 } else {
44 rt, err = tlsCache.get(config)
45 if err != nil {
46 return nil, err
47 }
48 }
49
50 return HTTPWrappersForConfig(config, rt)
51}
52
53// TLSConfigFor returns a tls.Config that will provide the transport level security defined
54// by the provided Config. Will return nil if no transport level security is requested.

Callers 2

TransportForFunction · 0.92
TestNewFunction · 0.70

Calls 6

HasCAMethod · 0.80
HasCertAuthMethod · 0.80
HasCertCallbackMethod · 0.80
HTTPWrappersForConfigFunction · 0.70
ErrorfMethod · 0.65
getMethod · 0.65

Tested by 1

TestNewFunction · 0.56