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

Function newServerVersion

cli/command/system/version.go:131–172  ·  view source on GitHub ↗
(sv client.ServerVersionResult)

Source from the content-addressed store, hash-verified

129}
130
131func newServerVersion(sv client.ServerVersionResult) *serverVersion {
132 out := &serverVersion{
133 Platform: sv.Platform,
134 Version: sv.Version,
135 APIVersion: sv.APIVersion,
136 MinAPIVersion: sv.MinAPIVersion,
137 Os: sv.Os,
138 Arch: sv.Arch,
139 Experimental: sv.Experimental, //nolint:staticcheck // ignore deprecated field.
140 Components: make([]system.ComponentVersion, 0, len(sv.Components)),
141 }
142 foundEngine := false
143 for _, component := range sv.Components {
144 if component.Name == "Engine" {
145 foundEngine = true
146 buildTime, ok := component.Details["BuildTime"]
147 if ok {
148 component.Details["BuildTime"] = reformatDate(buildTime)
149 }
150 out.GitCommit = component.Details["GitCommit"]
151 out.GoVersion = component.Details["GoVersion"]
152 out.KernelVersion = component.Details["KernelVersion"]
153 out.Experimental = func() bool { b, _ := strconv.ParseBool(component.Details["Experimental"]); return b }()
154 out.BuildTime = buildTime
155 }
156 out.Components = append(out.Components, component)
157 }
158
159 if !foundEngine {
160 out.Components = append(out.Components, system.ComponentVersion{
161 Name: "Engine",
162 Version: sv.Version,
163 Details: map[string]string{
164 "ApiVersion": sv.APIVersion,
165 "MinAPIVersion": sv.MinAPIVersion,
166 "Os": sv.Os,
167 "Arch": sv.Arch,
168 },
169 })
170 }
171 return out
172}
173
174// newVersionCommand creates a new cobra.Command for `docker version`
175func newVersionCommand(dockerCLI command.Cli) *cobra.Command {

Callers 1

runVersionFunction · 0.85

Calls 1

reformatDateFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…