1
0
Fork 0
mirror of https://github.com/moby/moby.git synced 2022-11-09 12:21:53 -05:00

remove useless lock

move job to server and remove version.go

Docker-DCO-1.1-Signed-off-by: Victor Vieux <victor.vieux@docker.com> (github: vieux)
This commit is contained in:
Victor Vieux 2014-03-10 21:23:29 +00:00
parent 3c7206b991
commit 6f70ed3a74
3 changed files with 25 additions and 42 deletions

View file

@ -36,5 +36,4 @@ func remote(eng *engine.Engine) {
func daemon(eng *engine.Engine) {
eng.Register("initserver", docker.InitServer)
eng.Register("init_networkdriver", lxc.InitDriver)
eng.Register("version", docker.GetVersion)
}

View file

@ -85,6 +85,7 @@ func InitServer(job *engine.Job) engine.Status {
"search": srv.ImagesSearch,
"changes": srv.ContainerChanges,
"top": srv.ContainerTop,
"version": srv.DockerVersion,
"load": srv.ImageLoad,
"build": srv.Build,
"pull": srv.ImagePull,
@ -836,6 +837,22 @@ func (srv *Server) DockerInfo(job *engine.Job) engine.Status {
return engine.StatusOK
}
func (srv *Server) DockerVersion(job *engine.Job) engine.Status {
v := &engine.Env{}
v.Set("Version", dockerversion.VERSION)
v.Set("GitCommit", dockerversion.GITCOMMIT)
v.Set("GoVersion", goruntime.Version())
v.Set("Os", goruntime.GOOS)
v.Set("Arch", goruntime.GOARCH)
if kernelVersion, err := utils.GetKernelVersion(); err == nil {
v.Set("KernelVersion", kernelVersion.String())
}
if _, err := v.WriteTo(job.Stdout); err != nil {
return job.Error(err)
}
return engine.StatusOK
}
func (srv *Server) ImageHistory(job *engine.Job) engine.Status {
if n := len(job.Args); n != 1 {
return job.Errorf("Usage: %s IMAGE", job.Name)
@ -2337,16 +2354,15 @@ func NewServer(eng *engine.Engine, config *daemonconfig.Config) (*Server, error)
}
func (srv *Server) HTTPRequestFactory(metaHeaders map[string][]string) *utils.HTTPRequestFactory {
srv.Lock()
defer srv.Unlock()
v := dockerVersion()
httpVersion := make([]utils.VersionInfo, 0, 4)
httpVersion = append(httpVersion, &simpleVersionInfo{"docker", v.Get("Version")})
httpVersion = append(httpVersion, &simpleVersionInfo{"go", v.Get("GoVersion")})
httpVersion = append(httpVersion, &simpleVersionInfo{"git-commit", v.Get("GitCommit")})
httpVersion = append(httpVersion, &simpleVersionInfo{"kernel", v.Get("KernelVersion")})
httpVersion = append(httpVersion, &simpleVersionInfo{"os", v.Get("Os")})
httpVersion = append(httpVersion, &simpleVersionInfo{"arch", v.Get("Arch")})
httpVersion = append(httpVersion, &simpleVersionInfo{"docker", dockerversion.VERSION})
httpVersion = append(httpVersion, &simpleVersionInfo{"go", goruntime.Version()})
httpVersion = append(httpVersion, &simpleVersionInfo{"git-commit", dockerversion.GITCOMMIT})
if kernelVersion, err := utils.GetKernelVersion(); err == nil {
httpVersion = append(httpVersion, &simpleVersionInfo{"kernel", kernelVersion.String()})
}
httpVersion = append(httpVersion, &simpleVersionInfo{"os", goruntime.GOOS})
httpVersion = append(httpVersion, &simpleVersionInfo{"arch", goruntime.GOARCH})
ud := utils.NewHTTPUserAgentDecorator(httpVersion...)
md := &utils.HTTPMetaHeadersDecorator{
Headers: metaHeaders,

View file

@ -1,32 +0,0 @@
package docker
import (
"github.com/dotcloud/docker/dockerversion"
"github.com/dotcloud/docker/engine"
"github.com/dotcloud/docker/utils"
"runtime"
)
func GetVersion(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", dockerversion.VERSION)
v.Set("GitCommit", dockerversion.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
}