mirror of https://github.com/docker/docs.git
Move docker version introspection to a sub-package.
This facilitates the refactoring of commands.go. Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
This commit is contained in:
parent
9176b6fd88
commit
ae3c7dec3b
|
@ -38,11 +38,6 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
GITCOMMIT string
|
|
||||||
VERSION string
|
|
||||||
)
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
ErrConnectionRefused = errors.New("Can't connect to docker daemon. Is 'docker -d' running on this host?")
|
ErrConnectionRefused = errors.New("Can't connect to docker daemon. Is 'docker -d' running on this host?")
|
||||||
)
|
)
|
||||||
|
|
|
@ -8,17 +8,13 @@ import (
|
||||||
|
|
||||||
"github.com/dotcloud/docker"
|
"github.com/dotcloud/docker"
|
||||||
"github.com/dotcloud/docker/api"
|
"github.com/dotcloud/docker/api"
|
||||||
|
"github.com/dotcloud/docker/dockerversion"
|
||||||
"github.com/dotcloud/docker/engine"
|
"github.com/dotcloud/docker/engine"
|
||||||
flag "github.com/dotcloud/docker/pkg/mflag"
|
flag "github.com/dotcloud/docker/pkg/mflag"
|
||||||
"github.com/dotcloud/docker/sysinit"
|
"github.com/dotcloud/docker/sysinit"
|
||||||
"github.com/dotcloud/docker/utils"
|
"github.com/dotcloud/docker/utils"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
|
||||||
GITCOMMIT string
|
|
||||||
VERSION string
|
|
||||||
)
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
if selfPath := utils.SelfPath(); selfPath == "/sbin/init" || selfPath == "/.dockerinit" {
|
if selfPath := utils.SelfPath(); selfPath == "/sbin/init" || selfPath == "/.dockerinit" {
|
||||||
// Running in init mode
|
// Running in init mode
|
||||||
|
@ -71,8 +67,6 @@ func main() {
|
||||||
if *flDebug {
|
if *flDebug {
|
||||||
os.Setenv("DEBUG", "1")
|
os.Setenv("DEBUG", "1")
|
||||||
}
|
}
|
||||||
docker.GITCOMMIT = GITCOMMIT
|
|
||||||
docker.VERSION = VERSION
|
|
||||||
if *flDaemon {
|
if *flDaemon {
|
||||||
if flag.NArg() != 0 {
|
if flag.NArg() != 0 {
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
|
@ -104,7 +98,7 @@ func main() {
|
||||||
job = eng.Job("serveapi", flHosts.GetAll()...)
|
job = eng.Job("serveapi", flHosts.GetAll()...)
|
||||||
job.SetenvBool("Logging", true)
|
job.SetenvBool("Logging", true)
|
||||||
job.SetenvBool("EnableCors", *flEnableCors)
|
job.SetenvBool("EnableCors", *flEnableCors)
|
||||||
job.Setenv("Version", VERSION)
|
job.Setenv("Version", dockerversion.VERSION)
|
||||||
if err := job.Run(); err != nil {
|
if err := job.Run(); err != nil {
|
||||||
log.Fatal(err)
|
log.Fatal(err)
|
||||||
}
|
}
|
||||||
|
@ -126,5 +120,5 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func showVersion() {
|
func showVersion() {
|
||||||
fmt.Printf("Docker version %s, build %s\n", VERSION, GITCOMMIT)
|
fmt.Printf("Docker version %s, build %s\n", dockerversion.VERSION, dockerversion.GITCOMMIT)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
package dockerversion
|
||||||
|
|
||||||
|
// FIXME: this should be embedded in the docker/docker.go,
|
||||||
|
// but we can't because distro policy requires us to
|
||||||
|
// package a separate dockerinit binary, and that binary needs
|
||||||
|
// to know its version too.
|
||||||
|
|
||||||
|
var (
|
||||||
|
GITCOMMIT string
|
||||||
|
VERSION string
|
||||||
|
)
|
|
@ -82,7 +82,7 @@ if [ ! "$GOPATH" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Use these flags when compiling the tests and final binary
|
# Use these flags when compiling the tests and final binary
|
||||||
LDFLAGS='-X main.GITCOMMIT "'$GITCOMMIT'" -X main.VERSION "'$VERSION'" -w'
|
LDFLAGS='-X github.com/dotcloud/docker/dockerversion.GITCOMMIT "'$GITCOMMIT'" -X github.com/dotcloud/docker/dockerversion.VERSION "'$VERSION'" -w'
|
||||||
LDFLAGS_STATIC='-X github.com/dotcloud/docker/utils.IAMSTATIC true -linkmode external -extldflags "-lpthread -static -Wl,--unresolved-symbols=ignore-in-object-files"'
|
LDFLAGS_STATIC='-X github.com/dotcloud/docker/utils.IAMSTATIC true -linkmode external -extldflags "-lpthread -static -Wl,--unresolved-symbols=ignore-in-object-files"'
|
||||||
BUILDFLAGS='-tags netgo -a'
|
BUILDFLAGS='-tags netgo -a'
|
||||||
|
|
||||||
|
|
|
@ -1,11 +1,20 @@
|
||||||
package docker
|
package docker
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"github.com/dotcloud/docker/dockerversion"
|
||||||
"github.com/dotcloud/docker/engine"
|
"github.com/dotcloud/docker/engine"
|
||||||
"github.com/dotcloud/docker/utils"
|
"github.com/dotcloud/docker/utils"
|
||||||
"runtime"
|
"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() {
|
func init() {
|
||||||
engine.Register("version", jobVersion)
|
engine.Register("version", jobVersion)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue