Merge pull request #4427 from thaJeztah/context_inline_vars

cli/context/docker: Endpoint.ClientOpts, withHTTPClient: inline variables
This commit is contained in:
Sebastiaan van Stijn 2023-07-17 13:08:29 +02:00 committed by GitHub
commit ce9f15c24c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 12 deletions

View File

@ -100,15 +100,13 @@ func (ep *Endpoint) ClientOpts() ([]client.Opt, error) {
)
} else {
httpClient := &http.Client{
// No tls
// No proxy
result = append(result,
client.WithHTTPClient(&http.Client{
// No TLS, and no proxy.
Transport: &http.Transport{
DialContext: helper.Dialer,
},
}
result = append(result,
client.WithHTTPClient(httpClient),
}),
client.WithHost(helper.Host),
client.WithDialContext(helper.Dialer),
)
@ -125,8 +123,7 @@ func withHTTPClient(tlsConfig *tls.Config) func(*client.Client) error {
// Use the default HTTPClient
return nil
}
httpClient := &http.Client{
return client.WithHTTPClient(&http.Client{
Transport: &http.Transport{
TLSClientConfig: tlsConfig,
DialContext: (&net.Dialer{
@ -135,8 +132,7 @@ func withHTTPClient(tlsConfig *tls.Config) func(*client.Client) error {
}).DialContext,
},
CheckRedirect: client.CheckRedirect,
}
return client.WithHTTPClient(httpClient)(c)
})(c)
}
}