2014-02-19 18:27:57 -05:00
|
|
|
package builtins
|
|
|
|
|
|
|
|
import (
|
2014-05-12 17:38:20 -04:00
|
|
|
"runtime"
|
|
|
|
|
2014-07-24 18:19:50 -04:00
|
|
|
"github.com/docker/docker/api"
|
|
|
|
apiserver "github.com/docker/docker/api/server"
|
2015-02-04 16:22:38 -05:00
|
|
|
"github.com/docker/docker/autogen/dockerversion"
|
2014-07-24 18:19:50 -04:00
|
|
|
"github.com/docker/docker/engine"
|
2014-07-28 20:23:38 -04:00
|
|
|
"github.com/docker/docker/pkg/parsers/kernel"
|
2014-02-19 18:27:57 -05:00
|
|
|
)
|
|
|
|
|
2014-05-02 20:54:52 -04:00
|
|
|
func Register(eng *engine.Engine) error {
|
|
|
|
if err := remote(eng); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2014-05-12 17:38:20 -04:00
|
|
|
if err := eng.Register("version", dockerVersion); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2014-08-20 11:31:24 -04:00
|
|
|
|
|
|
|
return nil
|
2014-02-19 18:27:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// remote: a RESTful api for cross-docker communication
|
2014-05-02 20:54:52 -04:00
|
|
|
func remote(eng *engine.Engine) error {
|
2014-05-02 20:11:20 -04:00
|
|
|
if err := eng.Register("serveapi", apiserver.ServeApi); err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
return eng.Register("acceptconnections", apiserver.AcceptConnections)
|
2014-02-19 18:27:57 -05:00
|
|
|
}
|
|
|
|
|
2014-05-12 17:38:20 -04:00
|
|
|
// builtins jobs independent of any subsystem
|
2015-03-25 03:44:12 -04:00
|
|
|
func dockerVersion(job *engine.Job) error {
|
2014-05-12 17:38:20 -04:00
|
|
|
v := &engine.Env{}
|
2014-06-08 19:06:47 -04:00
|
|
|
v.SetJson("Version", dockerversion.VERSION)
|
2014-05-12 17:38:20 -04:00
|
|
|
v.SetJson("ApiVersion", api.APIVERSION)
|
2014-09-15 19:35:07 -04:00
|
|
|
v.SetJson("GitCommit", dockerversion.GITCOMMIT)
|
2014-05-12 17:38:20 -04:00
|
|
|
v.Set("GoVersion", runtime.Version())
|
|
|
|
v.Set("Os", runtime.GOOS)
|
|
|
|
v.Set("Arch", runtime.GOARCH)
|
2014-07-28 20:23:38 -04:00
|
|
|
if kernelVersion, err := kernel.GetKernelVersion(); err == nil {
|
2014-05-12 17:38:20 -04:00
|
|
|
v.Set("KernelVersion", kernelVersion.String())
|
|
|
|
}
|
|
|
|
if _, err := v.WriteTo(job.Stdout); err != nil {
|
2015-03-25 03:44:12 -04:00
|
|
|
return err
|
2014-05-12 17:38:20 -04:00
|
|
|
}
|
2015-03-25 03:44:12 -04:00
|
|
|
return nil
|
2014-05-12 17:38:20 -04:00
|
|
|
}
|