mirror of https://github.com/docker/cli.git
cli/command: newAPIClientFromEndpoint: use WithUserAgent
More things to be done after this, to allow passing a custom user-agent, but let's start with just using this utility. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
7d723e2ba7
commit
2d06cfcde6
|
@ -260,17 +260,15 @@ func NewAPIClientFromFlags(opts *cliflags.ClientOptions, configFile *configfile.
|
||||||
}
|
}
|
||||||
|
|
||||||
func newAPIClientFromEndpoint(ep docker.Endpoint, configFile *configfile.ConfigFile) (client.APIClient, error) {
|
func newAPIClientFromEndpoint(ep docker.Endpoint, configFile *configfile.ConfigFile) (client.APIClient, error) {
|
||||||
clientOpts, err := ep.ClientOpts()
|
opts, err := ep.ClientOpts()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
customHeaders := make(map[string]string, len(configFile.HTTPHeaders))
|
if len(configFile.HTTPHeaders) > 0 {
|
||||||
for k, v := range configFile.HTTPHeaders {
|
opts = append(opts, client.WithHTTPHeaders(configFile.HTTPHeaders))
|
||||||
customHeaders[k] = v
|
|
||||||
}
|
}
|
||||||
customHeaders["User-Agent"] = UserAgent()
|
opts = append(opts, client.WithUserAgent(UserAgent()))
|
||||||
clientOpts = append(clientOpts, client.WithHTTPHeaders(customHeaders))
|
return client.NewClientWithOpts(opts...)
|
||||||
return client.NewClientWithOpts(clientOpts...)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func resolveDockerEndpoint(s store.Reader, contextName string) (docker.Endpoint, error) {
|
func resolveDockerEndpoint(s store.Reader, contextName string) (docker.Endpoint, error) {
|
||||||
|
|
Loading…
Reference in New Issue