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

Method TransportConfig

rest/transport.go:62–110  ·  view source on GitHub ↗

TransportConfig converts a client config to an appropriate transport config.

()

Source from the content-addressed store, hash-verified

60
61// TransportConfig converts a client config to an appropriate transport config.
62func (c *Config) TransportConfig() (*transport.Config, error) {
63 conf := &transport.Config{
64 UserAgent: c.UserAgent,
65 Transport: c.Transport,
66 WrapTransport: c.WrapTransport,
67 TLS: transport.TLSConfig{
68 Insecure: c.Insecure,
69 ServerName: c.ServerName,
70 CAFile: c.CAFile,
71 CAData: c.CAData,
72 CertFile: c.CertFile,
73 CertData: c.CertData,
74 KeyFile: c.KeyFile,
75 KeyData: c.KeyData,
76 },
77 Username: c.Username,
78 Password: c.Password,
79 BearerToken: c.BearerToken,
80 BearerTokenFile: c.BearerTokenFile,
81 Impersonate: transport.ImpersonationConfig{
82 UserName: c.Impersonate.UserName,
83 Groups: c.Impersonate.Groups,
84 Extra: c.Impersonate.Extra,
85 },
86 Dial: c.Dial,
87 }
88
89 if c.ExecProvider != nil && c.AuthProvider != nil {
90 return nil, errors.New("execProvider and authProvider cannot be used in combination")
91 }
92
93 if c.ExecProvider != nil {
94 provider, err := exec.GetAuthenticator(c.ExecProvider)
95 if err != nil {
96 return nil, err
97 }
98 if err := provider.UpdateTransportConfig(conf); err != nil {
99 return nil, err
100 }
101 }
102 if c.AuthProvider != nil {
103 provider, err := GetAuthProvider(c.Host, c.AuthProvider, c.AuthConfigPersister)
104 if err != nil {
105 return nil, err
106 }
107 conf.Wrap(provider.WrapTransport)
108 }
109 return conf, nil
110}
111
112// Wrap adds a transport middleware function that will give the caller
113// an opportunity to wrap the underlying http.RoundTripper prior to the

Callers 4

TLSConfigForFunction · 0.80
TransportForFunction · 0.80
HTTPWrappersForConfigFunction · 0.80

Calls 4

WrapMethod · 0.95
GetAuthenticatorFunction · 0.92
GetAuthProviderFunction · 0.85
UpdateTransportConfigMethod · 0.80

Tested by 1