Add bearer token support for kubelet client config

This commit is contained in:
Jordan Liggitt 2015-10-05 15:13:00 -04:00
parent 0aa5c16f38
commit 120e87277a
2 changed files with 13 additions and 4 deletions

View File

@ -100,6 +100,9 @@ type KubeletConfig struct {
// TLSClientConfig contains settings to enable transport layer security
TLSClientConfig
// Server requires Bearer authentication
BearerToken string
// HTTPTimeout is used by the client to timeout http requests to Kubelet.
HTTPTimeout time.Duration

View File

@ -50,14 +50,20 @@ func MakeTransport(config *KubeletConfig) (http.RoundTripper, error) {
if err != nil {
return nil, err
}
transport := http.DefaultTransport
if config.Dial != nil || tlsConfig != nil {
return util.SetTransportDefaults(&http.Transport{
transport = util.SetTransportDefaults(&http.Transport{
Dial: config.Dial,
TLSClientConfig: tlsConfig,
}), nil
} else {
return http.DefaultTransport, nil
})
}
if len(config.BearerToken) > 0 {
transport = NewBearerAuthRoundTripper(config.BearerToken, transport)
}
return transport, nil
}
// TODO: this structure is questionable, it should be using client.Config and overriding defaults.