github.com/feiyang21687/docker@v1.5.0/builtins/builtins.go (about) 1 package builtins 2 3 import ( 4 "runtime" 5 6 "github.com/docker/docker/api" 7 apiserver "github.com/docker/docker/api/server" 8 "github.com/docker/docker/daemon/networkdriver/bridge" 9 "github.com/docker/docker/dockerversion" 10 "github.com/docker/docker/engine" 11 "github.com/docker/docker/events" 12 "github.com/docker/docker/pkg/parsers/kernel" 13 ) 14 15 func Register(eng *engine.Engine) error { 16 if err := daemon(eng); err != nil { 17 return err 18 } 19 if err := remote(eng); err != nil { 20 return err 21 } 22 if err := events.New().Install(eng); err != nil { 23 return err 24 } 25 if err := eng.Register("version", dockerVersion); err != nil { 26 return err 27 } 28 29 return nil 30 } 31 32 // remote: a RESTful api for cross-docker communication 33 func remote(eng *engine.Engine) error { 34 if err := eng.Register("serveapi", apiserver.ServeApi); err != nil { 35 return err 36 } 37 return eng.Register("acceptconnections", apiserver.AcceptConnections) 38 } 39 40 // daemon: a default execution and storage backend for Docker on Linux, 41 // with the following underlying components: 42 // 43 // * Pluggable storage drivers including aufs, vfs, lvm and btrfs. 44 // * Pluggable execution drivers including lxc and chroot. 45 // 46 // In practice `daemon` still includes most core Docker components, including: 47 // 48 // * The reference registry client implementation 49 // * Image management 50 // * The build facility 51 // * Logging 52 // 53 // These components should be broken off into plugins of their own. 54 // 55 func daemon(eng *engine.Engine) error { 56 return eng.Register("init_networkdriver", bridge.InitDriver) 57 } 58 59 // builtins jobs independent of any subsystem 60 func dockerVersion(job *engine.Job) engine.Status { 61 v := &engine.Env{} 62 v.SetJson("Version", dockerversion.VERSION) 63 v.SetJson("ApiVersion", api.APIVERSION) 64 v.SetJson("GitCommit", dockerversion.GITCOMMIT) 65 v.Set("GoVersion", runtime.Version()) 66 v.Set("Os", runtime.GOOS) 67 v.Set("Arch", runtime.GOARCH) 68 if kernelVersion, err := kernel.GetKernelVersion(); err == nil { 69 v.Set("KernelVersion", kernelVersion.String()) 70 } 71 if _, err := v.WriteTo(job.Stdout); err != nil { 72 return job.Error(err) 73 } 74 return engine.StatusOK 75 }