mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
Move even more stuff into dockerversion
Also, use it in all the places. :) Docker-DCO-1.1-Signed-off-by: Andrew Page <admwiggin@gmail.com> (github: tianon)
This commit is contained in:
parent
ae3c7dec3b
commit
da04f49b38
9 changed files with 26 additions and 36 deletions
17
commands.go
17
commands.go
|
@ -11,6 +11,7 @@ import (
|
|||
"github.com/dotcloud/docker/api"
|
||||
"github.com/dotcloud/docker/archive"
|
||||
"github.com/dotcloud/docker/auth"
|
||||
"github.com/dotcloud/docker/dockerversion"
|
||||
"github.com/dotcloud/docker/engine"
|
||||
flag "github.com/dotcloud/docker/pkg/mflag"
|
||||
"github.com/dotcloud/docker/pkg/sysinfo"
|
||||
|
@ -383,12 +384,12 @@ func (cli *DockerCli) CmdVersion(args ...string) error {
|
|||
cmd.Usage()
|
||||
return nil
|
||||
}
|
||||
if VERSION != "" {
|
||||
fmt.Fprintf(cli.out, "Client version: %s\n", VERSION)
|
||||
if dockerversion.VERSION != "" {
|
||||
fmt.Fprintf(cli.out, "Client version: %s\n", dockerversion.VERSION)
|
||||
}
|
||||
fmt.Fprintf(cli.out, "Go version (client): %s\n", runtime.Version())
|
||||
if GITCOMMIT != "" {
|
||||
fmt.Fprintf(cli.out, "Git commit (client): %s\n", GITCOMMIT)
|
||||
if dockerversion.GITCOMMIT != "" {
|
||||
fmt.Fprintf(cli.out, "Git commit (client): %s\n", dockerversion.GITCOMMIT)
|
||||
}
|
||||
|
||||
body, _, err := readBody(cli.call("GET", "/version", nil, false))
|
||||
|
@ -413,7 +414,7 @@ func (cli *DockerCli) CmdVersion(args ...string) error {
|
|||
release := utils.GetReleaseVersion()
|
||||
if release != "" {
|
||||
fmt.Fprintf(cli.out, "Last stable version: %s", release)
|
||||
if (VERSION != "" || remoteVersion.Exists("Version")) && (strings.Trim(VERSION, "-dev") != release || strings.Trim(remoteVersion.Get("Version"), "-dev") != release) {
|
||||
if (dockerversion.VERSION != "" || remoteVersion.Exists("Version")) && (strings.Trim(dockerversion.VERSION, "-dev") != release || strings.Trim(remoteVersion.Get("Version"), "-dev") != release) {
|
||||
fmt.Fprintf(cli.out, ", please update docker")
|
||||
}
|
||||
fmt.Fprintf(cli.out, "\n")
|
||||
|
@ -2298,7 +2299,7 @@ func (cli *DockerCli) call(method, path string, data interface{}, passAuthInfo b
|
|||
}
|
||||
}
|
||||
}
|
||||
req.Header.Set("User-Agent", "Docker-Client/"+VERSION)
|
||||
req.Header.Set("User-Agent", "Docker-Client/"+dockerversion.VERSION)
|
||||
req.Host = cli.addr
|
||||
if data != nil {
|
||||
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
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.Header.Set("User-Agent", "Docker-Client/"+VERSION)
|
||||
req.Header.Set("User-Agent", "Docker-Client/"+dockerversion.VERSION)
|
||||
req.Host = cli.addr
|
||||
if method == "POST" {
|
||||
req.Header.Set("Content-Type", "plain/text")
|
||||
|
@ -2419,7 +2420,7 @@ func (cli *DockerCli) hijack(method, path string, setRawTerminal bool, in io.Rea
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
req.Header.Set("User-Agent", "Docker-Client/"+VERSION)
|
||||
req.Header.Set("User-Agent", "Docker-Client/"+dockerversion.VERSION)
|
||||
req.Header.Set("Content-Type", "plain/text")
|
||||
req.Host = cli.addr
|
||||
|
||||
|
|
|
@ -4,11 +4,6 @@ import (
|
|||
"github.com/dotcloud/docker/sysinit"
|
||||
)
|
||||
|
||||
var (
|
||||
GITCOMMIT string
|
||||
VERSION string
|
||||
)
|
||||
|
||||
func main() {
|
||||
// Running in init mode
|
||||
sysinit.SysInit()
|
||||
|
|
|
@ -8,4 +8,8 @@ package dockerversion
|
|||
var (
|
||||
GITCOMMIT string
|
||||
VERSION string
|
||||
|
||||
IAMSTATIC bool // whether or not Docker itself was compiled statically via ./hack/make.sh binary
|
||||
INITSHA1 string // sha1sum of separate static dockerinit, if Docker itself was compiled dynamically via ./hack/make.sh dynbinary
|
||||
INITPATH string // custom location to search for a valid dockerinit binary (available for packagers as a last resort escape hatch)
|
||||
)
|
||||
|
|
3
graph.go
3
graph.go
|
@ -3,6 +3,7 @@ package docker
|
|||
import (
|
||||
"fmt"
|
||||
"github.com/dotcloud/docker/archive"
|
||||
"github.com/dotcloud/docker/dockerversion"
|
||||
"github.com/dotcloud/docker/graphdriver"
|
||||
"github.com/dotcloud/docker/utils"
|
||||
"io"
|
||||
|
@ -130,7 +131,7 @@ func (graph *Graph) Create(layerData archive.Archive, container *Container, comm
|
|||
ID: GenerateID(),
|
||||
Comment: comment,
|
||||
Created: time.Now().UTC(),
|
||||
DockerVersion: VERSION,
|
||||
DockerVersion: dockerversion.VERSION,
|
||||
Author: author,
|
||||
Config: config,
|
||||
Architecture: runtime.GOARCH,
|
||||
|
|
|
@ -12,6 +12,6 @@ export DOCKER_INITSHA1="$(sha1sum $DEST/dockerinit-$VERSION | cut -d' ' -f1)"
|
|||
# exported so that "dyntest" can easily access it later without recalculating it
|
||||
|
||||
(
|
||||
export LDFLAGS_STATIC="-X github.com/dotcloud/docker/utils.INITSHA1 \"$DOCKER_INITSHA1\" -X github.com/dotcloud/docker/utils.INITPATH \"$DOCKER_INITPATH\""
|
||||
export LDFLAGS_STATIC="-X github.com/dotcloud/docker/dockerversion.INITSHA1 \"$DOCKER_INITSHA1\" -X github.com/dotcloud/docker/dockerversion.INITPATH \"$DOCKER_INITPATH\""
|
||||
source "$(dirname "$BASH_SOURCE")/binary"
|
||||
)
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"container/list"
|
||||
"fmt"
|
||||
"github.com/dotcloud/docker/archive"
|
||||
"github.com/dotcloud/docker/dockerversion"
|
||||
"github.com/dotcloud/docker/engine"
|
||||
"github.com/dotcloud/docker/execdriver"
|
||||
"github.com/dotcloud/docker/execdriver/chroot"
|
||||
|
@ -678,7 +679,7 @@ func NewRuntimeFromDirectory(config *DaemonConfig, eng *engine.Engine) (*Runtime
|
|||
return nil, err
|
||||
}
|
||||
|
||||
localCopy := path.Join(config.Root, "init", fmt.Sprintf("dockerinit-%s", VERSION))
|
||||
localCopy := path.Join(config.Root, "init", fmt.Sprintf("dockerinit-%s", dockerversion.VERSION))
|
||||
sysInitPath := utils.DockerInitPath(localCopy)
|
||||
if sysInitPath == "" {
|
||||
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 (
|
|||
"fmt"
|
||||
"github.com/dotcloud/docker/archive"
|
||||
"github.com/dotcloud/docker/auth"
|
||||
"github.com/dotcloud/docker/dockerversion"
|
||||
"github.com/dotcloud/docker/engine"
|
||||
"github.com/dotcloud/docker/pkg/graphdb"
|
||||
"github.com/dotcloud/docker/registry"
|
||||
|
@ -827,7 +828,7 @@ func (srv *Server) DockerInfo(job *engine.Job) engine.Status {
|
|||
v.SetInt("NEventsListener", len(srv.events))
|
||||
v.Set("KernelVersion", kernelVersion)
|
||||
v.Set("IndexServerAddress", auth.IndexServerAddress())
|
||||
v.Set("InitSha1", utils.INITSHA1)
|
||||
v.Set("InitSha1", dockerversion.INITSHA1)
|
||||
v.Set("InitPath", initPath)
|
||||
if _, err := v.WriteTo(job.Stdout); err != nil {
|
||||
return job.Error(err)
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"github.com/dotcloud/docker/dockerversion"
|
||||
"index/suffixarray"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
|
@ -23,12 +24,6 @@ import (
|
|||
"time"
|
||||
)
|
||||
|
||||
var (
|
||||
IAMSTATIC bool // whether or not Docker itself was compiled statically via ./hack/make.sh binary
|
||||
INITSHA1 string // sha1sum of separate static dockerinit, if Docker itself was compiled dynamically via ./hack/make.sh dynbinary
|
||||
INITPATH string // custom location to search for a valid dockerinit binary (available for packagers as a last resort escape hatch)
|
||||
)
|
||||
|
||||
// A common interface to access the Fatal method of
|
||||
// both testing.B and testing.T.
|
||||
type Fataler interface {
|
||||
|
@ -201,7 +196,7 @@ func isValidDockerInitPath(target string, selfPath string) bool { // target and
|
|||
if target == "" {
|
||||
return false
|
||||
}
|
||||
if IAMSTATIC {
|
||||
if dockerversion.IAMSTATIC {
|
||||
if selfPath == "" {
|
||||
return false
|
||||
}
|
||||
|
@ -218,7 +213,7 @@ func isValidDockerInitPath(target string, selfPath string) bool { // target and
|
|||
}
|
||||
return os.SameFile(targetFileInfo, selfPathFileInfo)
|
||||
}
|
||||
return INITSHA1 != "" && dockerInitSha1(target) == INITSHA1
|
||||
return dockerversion.INITSHA1 != "" && dockerInitSha1(target) == dockerversion.INITSHA1
|
||||
}
|
||||
|
||||
// Figure out the path of our dockerinit (which may be SelfPath())
|
||||
|
@ -230,7 +225,7 @@ func DockerInitPath(localCopy string) string {
|
|||
}
|
||||
var possibleInits = []string{
|
||||
localCopy,
|
||||
INITPATH,
|
||||
dockerversion.INITPATH,
|
||||
filepath.Join(filepath.Dir(selfPath), "dockerinit"),
|
||||
|
||||
// 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."
|
||||
|
|
12
version.go
12
version.go
|
@ -7,14 +7,6 @@ import (
|
|||
"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)
|
||||
}
|
||||
|
@ -31,8 +23,8 @@ func jobVersion(job *engine.Job) engine.Status {
|
|||
// environment.
|
||||
func dockerVersion() *engine.Env {
|
||||
v := &engine.Env{}
|
||||
v.Set("Version", VERSION)
|
||||
v.Set("GitCommit", GITCOMMIT)
|
||||
v.Set("Version", dockerversion.VERSION)
|
||||
v.Set("GitCommit", dockerversion.GITCOMMIT)
|
||||
v.Set("GoVersion", runtime.Version())
|
||||
v.Set("Os", runtime.GOOS)
|
||||
v.Set("Arch", runtime.GOARCH)
|
||||
|
|
Loading…
Reference in a new issue