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

Function addServerInfo

cli/command/system/info.go:119–142  ·  view source on GitHub ↗

addServerInfo retrieves the server information and adds it to the dockerInfo struct. if a connection error occurs, it will be returned as an error. other errors are appended to the info.ServerErrors field.

(ctx context.Context, dockerCli command.Cli, format string, info *dockerInfo)

Source from the content-addressed store, hash-verified

117// if a connection error occurs, it will be returned as an error.
118// other errors are appended to the info.ServerErrors field.
119func addServerInfo(ctx context.Context, dockerCli command.Cli, format string, info *dockerInfo) error {
120 res, err := dockerCli.Client().Info(ctx, client.InfoOptions{})
121 if err != nil {
122 // if no format is provided and we have an error, don't print the server info
123 if format == "" {
124 info.Info = nil
125 }
126 if !client.IsErrConnectionFailed(err) {
127 info.ServerErrors = append(info.ServerErrors, err.Error())
128 if format != "" {
129 // if a format is provided, print the error, as it may be hidden
130 // if the format template doesn't include the ServerErrors field.
131 fprintln(dockerCli.Err(), err)
132 }
133 return nil
134 }
135 // on a server connection error, we want to return an error
136 return err
137 }
138
139 // only assign the server info if we have no error
140 info.Info = &res.Info
141 return nil
142}
143
144// placeHolders does a rudimentary match for possible placeholders in a
145// template, matching a '.', followed by an letter (a-z/A-Z).

Callers 1

runInfoFunction · 0.85

Calls 5

fprintlnFunction · 0.85
ClientMethod · 0.65
ErrMethod · 0.65
InfoMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…