Allow client.Config to be used for HTTP2 and WebSocket connections
client.Config describes how to make a client connection to a server for HTTP traffic, but for connection upgrade scenarios cannot be used because the underlying http.Transport object can't allow the connection to be hijacked. Reorganize the TLS and connection wrapper methods so that a sophisticated client can do: cfg := &client.Config{...} // from somewhere tlsConfig, _ := client.TLSConfigFor(cfg) _ := conn.Dial(...) rt := MyRoundTripper() // some func that implements grabbing requests wrapper, _ := client.HTTPWrappersFor(cfg) req := &http.Request{} req.Header.Set("Connection-Upgrade", ...) _, := wrapper.RoundTrip(req) // rt has been invoked with a fully formed Req with auth rt.Req.Write(conn) // read response for upgrade It would be good to have utility function that does more of this, but mostly enabling the HTTP2/SPDY client exec function right now.
This commit is contained in:
@@ -147,9 +147,11 @@ func TestNewKubeletClientTLSInvalid(t *testing.T) {
|
||||
Port: 9000,
|
||||
EnableHttps: true,
|
||||
//Invalid certificate and key path
|
||||
CertFile: "./testdata/mycertinvalid.cer",
|
||||
KeyFile: "./testdata/mycertinvalid.key",
|
||||
CAFile: "./testdata/myCA.cer",
|
||||
TLSClientConfig: TLSClientConfig{
|
||||
CertFile: "./testdata/mycertinvalid.cer",
|
||||
KeyFile: "./testdata/mycertinvalid.key",
|
||||
CAFile: "./testdata/myCA.cer",
|
||||
},
|
||||
}
|
||||
|
||||
client, err := NewKubeletClient(config)
|
||||
@@ -165,11 +167,13 @@ func TestNewKubeletClientTLSValid(t *testing.T) {
|
||||
config := &KubeletConfig{
|
||||
Port: 9000,
|
||||
EnableHttps: true,
|
||||
CertFile: "./testdata/mycertvalid.cer",
|
||||
// TLS Configuration, only applies if EnableHttps is true.
|
||||
KeyFile: "./testdata/mycertvalid.key",
|
||||
// TLS Configuration, only applies if EnableHttps is true.
|
||||
CAFile: "./testdata/myCA.cer",
|
||||
TLSClientConfig: TLSClientConfig{
|
||||
CertFile: "./testdata/mycertvalid.cer",
|
||||
// TLS Configuration, only applies if EnableHttps is true.
|
||||
KeyFile: "./testdata/mycertvalid.key",
|
||||
// TLS Configuration, only applies if EnableHttps is true.
|
||||
CAFile: "./testdata/myCA.cer",
|
||||
},
|
||||
}
|
||||
|
||||
client, err := NewKubeletClient(config)
|
||||
|
Reference in New Issue
Block a user