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
5 changed files with 24 additions and 15 deletions
|
@ -38,11 +38,6 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
GITCOMMIT string
|
||||
VERSION string
|
||||
)
|
||||
|
||||
var (
|
||||
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/api"
|
||||
"github.com/dotcloud/docker/dockerversion"
|
||||
"github.com/dotcloud/docker/engine"
|
||||
flag "github.com/dotcloud/docker/pkg/mflag"
|
||||
"github.com/dotcloud/docker/sysinit"
|
||||
"github.com/dotcloud/docker/utils"
|
||||
)
|
||||
|
||||
var (
|
||||
GITCOMMIT string
|
||||
VERSION string
|
||||
)
|
||||
|
||||
func main() {
|
||||
if selfPath := utils.SelfPath(); selfPath == "/sbin/init" || selfPath == "/.dockerinit" {
|
||||
// Running in init mode
|
||||
|
@ -71,8 +67,6 @@ func main() {
|
|||
if *flDebug {
|
||||
os.Setenv("DEBUG", "1")
|
||||
}
|
||||
docker.GITCOMMIT = GITCOMMIT
|
||||
docker.VERSION = VERSION
|
||||
if *flDaemon {
|
||||
if flag.NArg() != 0 {
|
||||
flag.Usage()
|
||||
|
@ -104,7 +98,7 @@ func main() {
|
|||
job = eng.Job("serveapi", flHosts.GetAll()...)
|
||||
job.SetenvBool("Logging", true)
|
||||
job.SetenvBool("EnableCors", *flEnableCors)
|
||||
job.Setenv("Version", VERSION)
|
||||
job.Setenv("Version", dockerversion.VERSION)
|
||||
if err := job.Run(); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
@ -126,5 +120,5 @@ func main() {
|
|||
}
|
||||
|
||||
func showVersion() {
|
||||
fmt.Printf("Docker version %s, build %s\n", VERSION, GITCOMMIT)
|
||||
fmt.Printf("Docker version %s, build %s\n", dockerversion.VERSION, dockerversion.GITCOMMIT)
|
||||
}
|
||||
|
|
11
dockerversion/dockerversion.go
Normal file
11
dockerversion/dockerversion.go
Normal file
|
@ -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
|
||||
|
||||
# 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"'
|
||||
BUILDFLAGS='-tags netgo -a'
|
||||
|
||||
|
|
|
@ -1,11 +1,20 @@
|
|||
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)
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue