Resolve the Docker endpoint for the default context (based on config, env vars and CLI flags)
(opts *cliflags.ClientOptions)
| 336 | |
| 337 | // Resolve the Docker endpoint for the default context (based on config, env vars and CLI flags) |
| 338 | func resolveDefaultDockerEndpoint(opts *cliflags.ClientOptions) (docker.Endpoint, error) { |
| 339 | // defaultToTLS determines whether we should use a TLS host as default |
| 340 | // if nothing was configured by the user. |
| 341 | defaultToTLS := opts.TLSOptions != nil |
| 342 | host, err := getServerHost(opts.Hosts, defaultToTLS) |
| 343 | if err != nil { |
| 344 | return docker.Endpoint{}, err |
| 345 | } |
| 346 | |
| 347 | var ( |
| 348 | skipTLSVerify bool |
| 349 | tlsData *dcontext.TLSData |
| 350 | ) |
| 351 | |
| 352 | if opts.TLSOptions != nil { |
| 353 | skipTLSVerify = opts.TLSOptions.InsecureSkipVerify |
| 354 | tlsData, err = dcontext.TLSDataFromFiles(opts.TLSOptions.CAFile, opts.TLSOptions.CertFile, opts.TLSOptions.KeyFile) |
| 355 | if err != nil { |
| 356 | return docker.Endpoint{}, err |
| 357 | } |
| 358 | } |
| 359 | |
| 360 | return docker.Endpoint{ |
| 361 | EndpointMeta: docker.EndpointMeta{ |
| 362 | Host: host, |
| 363 | SkipTLSVerify: skipTLSVerify, |
| 364 | }, |
| 365 | TLSData: tlsData, |
| 366 | }, nil |
| 367 | } |
| 368 | |
| 369 | func (cli *DockerCli) getInitTimeout() time.Duration { |
| 370 | if cli.initTimeout != 0 { |
no test coverage detected
searching dependent graphs…