Also, use it in all the places. :)
Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
| ... | ... |
@@ -11,6 +11,7 @@ import ( |
| 11 | 11 |
"github.com/dotcloud/docker/api" |
| 12 | 12 |
"github.com/dotcloud/docker/archive" |
| 13 | 13 |
"github.com/dotcloud/docker/auth" |
| 14 |
+ "github.com/dotcloud/docker/dockerversion" |
|
| 14 | 15 |
"github.com/dotcloud/docker/engine" |
| 15 | 16 |
flag "github.com/dotcloud/docker/pkg/mflag" |
| 16 | 17 |
"github.com/dotcloud/docker/pkg/sysinfo" |
| ... | ... |
@@ -383,12 +384,12 @@ func (cli *DockerCli) CmdVersion(args ...string) error {
|
| 383 | 383 |
cmd.Usage() |
| 384 | 384 |
return nil |
| 385 | 385 |
} |
| 386 |
- if VERSION != "" {
|
|
| 387 |
- fmt.Fprintf(cli.out, "Client version: %s\n", VERSION) |
|
| 386 |
+ if dockerversion.VERSION != "" {
|
|
| 387 |
+ fmt.Fprintf(cli.out, "Client version: %s\n", dockerversion.VERSION) |
|
| 388 | 388 |
} |
| 389 | 389 |
fmt.Fprintf(cli.out, "Go version (client): %s\n", runtime.Version()) |
| 390 |
- if GITCOMMIT != "" {
|
|
| 391 |
- fmt.Fprintf(cli.out, "Git commit (client): %s\n", GITCOMMIT) |
|
| 390 |
+ if dockerversion.GITCOMMIT != "" {
|
|
| 391 |
+ fmt.Fprintf(cli.out, "Git commit (client): %s\n", dockerversion.GITCOMMIT) |
|
| 392 | 392 |
} |
| 393 | 393 |
|
| 394 | 394 |
body, _, err := readBody(cli.call("GET", "/version", nil, false))
|
| ... | ... |
@@ -413,7 +414,7 @@ func (cli *DockerCli) CmdVersion(args ...string) error {
|
| 413 | 413 |
release := utils.GetReleaseVersion() |
| 414 | 414 |
if release != "" {
|
| 415 | 415 |
fmt.Fprintf(cli.out, "Last stable version: %s", release) |
| 416 |
- if (VERSION != "" || remoteVersion.Exists("Version")) && (strings.Trim(VERSION, "-dev") != release || strings.Trim(remoteVersion.Get("Version"), "-dev") != release) {
|
|
| 416 |
+ if (dockerversion.VERSION != "" || remoteVersion.Exists("Version")) && (strings.Trim(dockerversion.VERSION, "-dev") != release || strings.Trim(remoteVersion.Get("Version"), "-dev") != release) {
|
|
| 417 | 417 |
fmt.Fprintf(cli.out, ", please update docker") |
| 418 | 418 |
} |
| 419 | 419 |
fmt.Fprintf(cli.out, "\n") |
| ... | ... |
@@ -2298,7 +2299,7 @@ func (cli *DockerCli) call(method, path string, data interface{}, passAuthInfo b
|
| 2298 | 2298 |
} |
| 2299 | 2299 |
} |
| 2300 | 2300 |
} |
| 2301 |
- req.Header.Set("User-Agent", "Docker-Client/"+VERSION)
|
|
| 2301 |
+ req.Header.Set("User-Agent", "Docker-Client/"+dockerversion.VERSION)
|
|
| 2302 | 2302 |
req.Host = cli.addr |
| 2303 | 2303 |
if data != nil {
|
| 2304 | 2304 |
req.Header.Set("Content-Type", "application/json")
|
| ... | ... |
@@ -2355,7 +2356,7 @@ func (cli *DockerCli) stream(method, path string, in io.Reader, out io.Writer, h |
| 2355 | 2355 |
if err != nil {
|
| 2356 | 2356 |
return err |
| 2357 | 2357 |
} |
| 2358 |
- req.Header.Set("User-Agent", "Docker-Client/"+VERSION)
|
|
| 2358 |
+ req.Header.Set("User-Agent", "Docker-Client/"+dockerversion.VERSION)
|
|
| 2359 | 2359 |
req.Host = cli.addr |
| 2360 | 2360 |
if method == "POST" {
|
| 2361 | 2361 |
req.Header.Set("Content-Type", "plain/text")
|
| ... | ... |
@@ -2419,7 +2420,7 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea |
| 2419 | 2419 |
if err != nil {
|
| 2420 | 2420 |
return err |
| 2421 | 2421 |
} |
| 2422 |
- req.Header.Set("User-Agent", "Docker-Client/"+VERSION)
|
|
| 2422 |
+ req.Header.Set("User-Agent", "Docker-Client/"+dockerversion.VERSION)
|
|
| 2423 | 2423 |
req.Header.Set("Content-Type", "plain/text")
|
| 2424 | 2424 |
req.Host = cli.addr |
| 2425 | 2425 |
|
| ... | ... |
@@ -8,4 +8,8 @@ package dockerversion |
| 8 | 8 |
var ( |
| 9 | 9 |
GITCOMMIT string |
| 10 | 10 |
VERSION string |
| 11 |
+ |
|
| 12 |
+ IAMSTATIC bool // whether or not Docker itself was compiled statically via ./hack/make.sh binary |
|
| 13 |
+ INITSHA1 string // sha1sum of separate static dockerinit, if Docker itself was compiled dynamically via ./hack/make.sh dynbinary |
|
| 14 |
+ INITPATH string // custom location to search for a valid dockerinit binary (available for packagers as a last resort escape hatch) |
|
| 11 | 15 |
) |
| ... | ... |
@@ -3,6 +3,7 @@ package docker |
| 3 | 3 |
import ( |
| 4 | 4 |
"fmt" |
| 5 | 5 |
"github.com/dotcloud/docker/archive" |
| 6 |
+ "github.com/dotcloud/docker/dockerversion" |
|
| 6 | 7 |
"github.com/dotcloud/docker/graphdriver" |
| 7 | 8 |
"github.com/dotcloud/docker/utils" |
| 8 | 9 |
"io" |
| ... | ... |
@@ -130,7 +131,7 @@ func (graph *Graph) Create(layerData archive.Archive, container *Container, comm |
| 130 | 130 |
ID: GenerateID(), |
| 131 | 131 |
Comment: comment, |
| 132 | 132 |
Created: time.Now().UTC(), |
| 133 |
- DockerVersion: VERSION, |
|
| 133 |
+ DockerVersion: dockerversion.VERSION, |
|
| 134 | 134 |
Author: author, |
| 135 | 135 |
Config: config, |
| 136 | 136 |
Architecture: runtime.GOARCH, |
| ... | ... |
@@ -12,6 +12,6 @@ export DOCKER_INITSHA1="$(sha1sum $DEST/dockerinit-$VERSION | cut -d' ' -f1)" |
| 12 | 12 |
# exported so that "dyntest" can easily access it later without recalculating it |
| 13 | 13 |
|
| 14 | 14 |
( |
| 15 |
- export LDFLAGS_STATIC="-X github.com/dotcloud/docker/utils.INITSHA1 \"$DOCKER_INITSHA1\" -X github.com/dotcloud/docker/utils.INITPATH \"$DOCKER_INITPATH\"" |
|
| 15 |
+ export LDFLAGS_STATIC="-X github.com/dotcloud/docker/dockerversion.INITSHA1 \"$DOCKER_INITSHA1\" -X github.com/dotcloud/docker/dockerversion.INITPATH \"$DOCKER_INITPATH\"" |
|
| 16 | 16 |
source "$(dirname "$BASH_SOURCE")/binary" |
| 17 | 17 |
) |
| ... | ... |
@@ -4,6 +4,7 @@ import ( |
| 4 | 4 |
"container/list" |
| 5 | 5 |
"fmt" |
| 6 | 6 |
"github.com/dotcloud/docker/archive" |
| 7 |
+ "github.com/dotcloud/docker/dockerversion" |
|
| 7 | 8 |
"github.com/dotcloud/docker/engine" |
| 8 | 9 |
"github.com/dotcloud/docker/execdriver" |
| 9 | 10 |
"github.com/dotcloud/docker/execdriver/chroot" |
| ... | ... |
@@ -678,7 +679,7 @@ func NewRuntimeFromDirectory(config *DaemonConfig, eng *engine.Engine) (*Runtime |
| 678 | 678 |
return nil, err |
| 679 | 679 |
} |
| 680 | 680 |
|
| 681 |
- localCopy := path.Join(config.Root, "init", fmt.Sprintf("dockerinit-%s", VERSION))
|
|
| 681 |
+ localCopy := path.Join(config.Root, "init", fmt.Sprintf("dockerinit-%s", dockerversion.VERSION))
|
|
| 682 | 682 |
sysInitPath := utils.DockerInitPath(localCopy) |
| 683 | 683 |
if sysInitPath == "" {
|
| 684 | 684 |
return nil, fmt.Errorf("Could not locate dockerinit: This usually means docker was built incorrectly. See http://docs.docker.io/en/latest/contributing/devenvironment for official build instructions.")
|
| ... | ... |
@@ -6,6 +6,7 @@ import ( |
| 6 | 6 |
"fmt" |
| 7 | 7 |
"github.com/dotcloud/docker/archive" |
| 8 | 8 |
"github.com/dotcloud/docker/auth" |
| 9 |
+ "github.com/dotcloud/docker/dockerversion" |
|
| 9 | 10 |
"github.com/dotcloud/docker/engine" |
| 10 | 11 |
"github.com/dotcloud/docker/pkg/graphdb" |
| 11 | 12 |
"github.com/dotcloud/docker/registry" |
| ... | ... |
@@ -827,7 +828,7 @@ func (srv *Server) DockerInfo(job *engine.Job) engine.Status {
|
| 827 | 827 |
v.SetInt("NEventsListener", len(srv.events))
|
| 828 | 828 |
v.Set("KernelVersion", kernelVersion)
|
| 829 | 829 |
v.Set("IndexServerAddress", auth.IndexServerAddress())
|
| 830 |
- v.Set("InitSha1", utils.INITSHA1)
|
|
| 830 |
+ v.Set("InitSha1", dockerversion.INITSHA1)
|
|
| 831 | 831 |
v.Set("InitPath", initPath)
|
| 832 | 832 |
if _, err := v.WriteTo(job.Stdout); err != nil {
|
| 833 | 833 |
return job.Error(err) |
| ... | ... |
@@ -8,6 +8,7 @@ import ( |
| 8 | 8 |
"encoding/json" |
| 9 | 9 |
"errors" |
| 10 | 10 |
"fmt" |
| 11 |
+ "github.com/dotcloud/docker/dockerversion" |
|
| 11 | 12 |
"index/suffixarray" |
| 12 | 13 |
"io" |
| 13 | 14 |
"io/ioutil" |
| ... | ... |
@@ -23,12 +24,6 @@ import ( |
| 23 | 23 |
"time" |
| 24 | 24 |
) |
| 25 | 25 |
|
| 26 |
-var ( |
|
| 27 |
- IAMSTATIC bool // whether or not Docker itself was compiled statically via ./hack/make.sh binary |
|
| 28 |
- INITSHA1 string // sha1sum of separate static dockerinit, if Docker itself was compiled dynamically via ./hack/make.sh dynbinary |
|
| 29 |
- INITPATH string // custom location to search for a valid dockerinit binary (available for packagers as a last resort escape hatch) |
|
| 30 |
-) |
|
| 31 |
- |
|
| 32 | 26 |
// A common interface to access the Fatal method of |
| 33 | 27 |
// both testing.B and testing.T. |
| 34 | 28 |
type Fataler interface {
|
| ... | ... |
@@ -201,7 +196,7 @@ func isValidDockerInitPath(target string, selfPath string) bool { // target and
|
| 201 | 201 |
if target == "" {
|
| 202 | 202 |
return false |
| 203 | 203 |
} |
| 204 |
- if IAMSTATIC {
|
|
| 204 |
+ if dockerversion.IAMSTATIC {
|
|
| 205 | 205 |
if selfPath == "" {
|
| 206 | 206 |
return false |
| 207 | 207 |
} |
| ... | ... |
@@ -218,7 +213,7 @@ func isValidDockerInitPath(target string, selfPath string) bool { // target and
|
| 218 | 218 |
} |
| 219 | 219 |
return os.SameFile(targetFileInfo, selfPathFileInfo) |
| 220 | 220 |
} |
| 221 |
- return INITSHA1 != "" && dockerInitSha1(target) == INITSHA1 |
|
| 221 |
+ return dockerversion.INITSHA1 != "" && dockerInitSha1(target) == dockerversion.INITSHA1 |
|
| 222 | 222 |
} |
| 223 | 223 |
|
| 224 | 224 |
// Figure out the path of our dockerinit (which may be SelfPath()) |
| ... | ... |
@@ -230,7 +225,7 @@ func DockerInitPath(localCopy string) string {
|
| 230 | 230 |
} |
| 231 | 231 |
var possibleInits = []string{
|
| 232 | 232 |
localCopy, |
| 233 |
- INITPATH, |
|
| 233 |
+ dockerversion.INITPATH, |
|
| 234 | 234 |
filepath.Join(filepath.Dir(selfPath), "dockerinit"), |
| 235 | 235 |
|
| 236 | 236 |
// FHS 3.0 Draft: "/usr/libexec includes internal binaries that are not intended to be executed directly by users or shell scripts. Applications may use a single subdirectory under /usr/libexec." |
| ... | ... |
@@ -7,14 +7,6 @@ import ( |
| 7 | 7 |
"runtime" |
| 8 | 8 |
) |
| 9 | 9 |
|
| 10 |
-var ( |
|
| 11 |
- // FIXME: this is a convenience indirection to preserve legacy |
|
| 12 |
- // code. It can be removed by using dockerversion.VERSION and |
|
| 13 |
- // dockerversion.GITCOMMIT directly |
|
| 14 |
- GITCOMMIT string = dockerversion.GITCOMMIT |
|
| 15 |
- VERSION string = dockerversion.VERSION |
|
| 16 |
-) |
|
| 17 |
- |
|
| 18 | 10 |
func init() {
|
| 19 | 11 |
engine.Register("version", jobVersion)
|
| 20 | 12 |
} |
| ... | ... |
@@ -31,8 +23,8 @@ func jobVersion(job *engine.Job) engine.Status {
|
| 31 | 31 |
// environment. |
| 32 | 32 |
func dockerVersion() *engine.Env {
|
| 33 | 33 |
v := &engine.Env{}
|
| 34 |
- v.Set("Version", VERSION)
|
|
| 35 |
- v.Set("GitCommit", GITCOMMIT)
|
|
| 34 |
+ v.Set("Version", dockerversion.VERSION)
|
|
| 35 |
+ v.Set("GitCommit", dockerversion.GITCOMMIT)
|
|
| 36 | 36 |
v.Set("GoVersion", runtime.Version())
|
| 37 | 37 |
v.Set("Os", runtime.GOOS)
|
| 38 | 38 |
v.Set("Arch", runtime.GOARCH)
|