mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
ae3c7dec3b
This facilitates the refactoring of commands.go. Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
44 lines
1.1 KiB
Go
44 lines
1.1 KiB
Go
package docker
|
|
|
|
import (
|
|
"github.com/dotcloud/docker/dockerversion"
|
|
"github.com/dotcloud/docker/engine"
|
|
"github.com/dotcloud/docker/utils"
|
|
"runtime"
|
|
)
|
|
|
|
var (
|
|
// FIXME: this is a convenience indirection to preserve legacy
|
|
// code. It can be removed by using dockerversion.VERSION and
|
|
// dockerversion.GITCOMMIT directly
|
|
GITCOMMIT string = dockerversion.GITCOMMIT
|
|
VERSION string = dockerversion.VERSION
|
|
)
|
|
|
|
func init() {
|
|
engine.Register("version", jobVersion)
|
|
}
|
|
|
|
func jobVersion(job *engine.Job) engine.Status {
|
|
if _, err := dockerVersion().WriteTo(job.Stdout); err != nil {
|
|
job.Errorf("%s", err)
|
|
return engine.StatusErr
|
|
}
|
|
return engine.StatusOK
|
|
}
|
|
|
|
// dockerVersion returns detailed version information in the form of a queriable
|
|
// environment.
|
|
func dockerVersion() *engine.Env {
|
|
v := &engine.Env{}
|
|
v.Set("Version", VERSION)
|
|
v.Set("GitCommit", GITCOMMIT)
|
|
v.Set("GoVersion", runtime.Version())
|
|
v.Set("Os", runtime.GOOS)
|
|
v.Set("Arch", runtime.GOARCH)
|
|
// FIXME:utils.GetKernelVersion should only be needed here
|
|
if kernelVersion, err := utils.GetKernelVersion(); err == nil {
|
|
v.Set("KernelVersion", kernelVersion.String())
|
|
}
|
|
return v
|
|
}
|