NewDockerCli returns a DockerCli instance with all operators applied on it. It applies by default the standard streams, and the content trust from environment.
(ops ...CLIOption)
| 566 | // It applies by default the standard streams, and the content trust from |
| 567 | // environment. |
| 568 | func NewDockerCli(ops ...CLIOption) (*DockerCli, error) { |
| 569 | defaultOps := make([]CLIOption, 0, 3+len(ops)) |
| 570 | defaultOps = append(defaultOps, |
| 571 | WithDefaultContextStoreConfig(), |
| 572 | WithStandardStreams(), |
| 573 | WithUserAgent(UserAgent()), |
| 574 | ) |
| 575 | ops = append(defaultOps, ops...) |
| 576 | |
| 577 | cli := &DockerCli{baseCtx: context.Background()} |
| 578 | for _, op := range ops { |
| 579 | if err := op(cli); err != nil { |
| 580 | return nil, err |
| 581 | } |
| 582 | } |
| 583 | return cli, nil |
| 584 | } |
| 585 | |
| 586 | func getServerHost(hosts []string, defaultToTLS bool) (string, error) { |
| 587 | switch len(hosts) { |
searching dependent graphs…