MCPcopy Index your code
hub / github.com/docker/cli / NewAPIClientFromFlags

Function NewAPIClientFromFlags

cli/command/cli.go:284–301  ·  view source on GitHub ↗

NewAPIClientFromFlags creates a new APIClient from command line flags

(opts *cliflags.ClientOptions, configFile *configfile.ConfigFile)

Source from the content-addressed store, hash-verified

282
283// NewAPIClientFromFlags creates a new APIClient from command line flags
284func NewAPIClientFromFlags(opts *cliflags.ClientOptions, configFile *configfile.ConfigFile) (client.APIClient, error) {
285 if opts.Context != "" && len(opts.Hosts) > 0 {
286 return nil, errors.New("conflicting options: cannot specify both --host and --context")
287 }
288
289 storeConfig := DefaultContextStoreConfig()
290 contextStore := &ContextStoreWithDefault{
291 Store: store.New(config.ContextStoreDir(), storeConfig),
292 Resolver: func() (*DefaultContext, error) {
293 return resolveDefaultContext(opts, storeConfig)
294 },
295 }
296 endpoint, err := resolveDockerEndpoint(contextStore, resolveContextName(opts, configFile))
297 if err != nil {
298 return nil, fmt.Errorf("unable to resolve docker endpoint: %w", err)
299 }
300 return newAPIClientFromEndpoint(endpoint, configFile, client.WithUserAgent(UserAgent()))
301}
302
303func newAPIClientFromEndpoint(ep docker.Endpoint, configFile *configfile.ConfigFile, extraOpts ...client.Opt) (client.APIClient, error) {
304 opts, err := ep.ClientOpts()

Calls 6

resolveDefaultContextFunction · 0.85
resolveDockerEndpointFunction · 0.85
resolveContextNameFunction · 0.85
newAPIClientFromEndpointFunction · 0.85
UserAgentFunction · 0.85

Used in the wild real call sites across dependent graphs

searching dependent graphs…