(ctx context.Context, cmd *cobra.Command, dockerCli command.Cli, opts *infoOptions)
| 83 | } |
| 84 | |
| 85 | func runInfo(ctx context.Context, cmd *cobra.Command, dockerCli command.Cli, opts *infoOptions) error { |
| 86 | info := dockerInfo{ |
| 87 | ClientInfo: &clientInfo{ |
| 88 | // Don't pass a dockerCLI to newClientVersion(), because we currently |
| 89 | // don't include negotiated API version, and want to avoid making an |
| 90 | // API connection when only printing the Client section. |
| 91 | clientVersion: newClientVersion(dockerCli.CurrentContext(), nil), |
| 92 | Debug: debug.IsEnabled(), |
| 93 | }, |
| 94 | Info: &system.Info{}, |
| 95 | } |
| 96 | if plugins, err := pluginmanager.ListPlugins(dockerCli, cmd.Root()); err == nil { |
| 97 | info.ClientInfo.Plugins = plugins |
| 98 | } else { |
| 99 | info.ClientErrors = append(info.ClientErrors, err.Error()) |
| 100 | } |
| 101 | |
| 102 | var serverConnErr error |
| 103 | if needsServerInfo(opts.format, info) { |
| 104 | serverConnErr = addServerInfo(ctx, dockerCli, opts.format, &info) |
| 105 | } |
| 106 | |
| 107 | if opts.format == "" { |
| 108 | info.UserName = dockerCli.ConfigFile().AuthConfigs[registry.IndexServer].Username |
| 109 | info.ClientInfo.APIVersion = dockerCli.CurrentVersion() |
| 110 | return errors.Join(prettyPrintInfo(dockerCli, info), serverConnErr) |
| 111 | } |
| 112 | |
| 113 | return errors.Join(serverConnErr, formatInfo(dockerCli.Out(), info, opts.format)) |
| 114 | } |
| 115 | |
| 116 | // addServerInfo retrieves the server information and adds it to the dockerInfo struct. |
| 117 | // if a connection error occurs, it will be returned as an error. |
no test coverage detected
searching dependent graphs…