This facilitates the refactoring of commands.go.
Docker-DCO-1.1-Signed-off-by: Solomon Hykes <solomon@docker.com> (github: shykes)
| ... | ... |
@@ -8,17 +8,13 @@ import ( |
| 8 | 8 |
|
| 9 | 9 |
"github.com/dotcloud/docker" |
| 10 | 10 |
"github.com/dotcloud/docker/api" |
| 11 |
+ "github.com/dotcloud/docker/dockerversion" |
|
| 11 | 12 |
"github.com/dotcloud/docker/engine" |
| 12 | 13 |
flag "github.com/dotcloud/docker/pkg/mflag" |
| 13 | 14 |
"github.com/dotcloud/docker/sysinit" |
| 14 | 15 |
"github.com/dotcloud/docker/utils" |
| 15 | 16 |
) |
| 16 | 17 |
|
| 17 |
-var ( |
|
| 18 |
- GITCOMMIT string |
|
| 19 |
- VERSION string |
|
| 20 |
-) |
|
| 21 |
- |
|
| 22 | 18 |
func main() {
|
| 23 | 19 |
if selfPath := utils.SelfPath(); selfPath == "/sbin/init" || selfPath == "/.dockerinit" {
|
| 24 | 20 |
// Running in init mode |
| ... | ... |
@@ -71,8 +67,6 @@ func main() {
|
| 71 | 71 |
if *flDebug {
|
| 72 | 72 |
os.Setenv("DEBUG", "1")
|
| 73 | 73 |
} |
| 74 |
- docker.GITCOMMIT = GITCOMMIT |
|
| 75 |
- docker.VERSION = VERSION |
|
| 76 | 74 |
if *flDaemon {
|
| 77 | 75 |
if flag.NArg() != 0 {
|
| 78 | 76 |
flag.Usage() |
| ... | ... |
@@ -104,7 +98,7 @@ func main() {
|
| 104 | 104 |
job = eng.Job("serveapi", flHosts.GetAll()...)
|
| 105 | 105 |
job.SetenvBool("Logging", true)
|
| 106 | 106 |
job.SetenvBool("EnableCors", *flEnableCors)
|
| 107 |
- job.Setenv("Version", VERSION)
|
|
| 107 |
+ job.Setenv("Version", dockerversion.VERSION)
|
|
| 108 | 108 |
if err := job.Run(); err != nil {
|
| 109 | 109 |
log.Fatal(err) |
| 110 | 110 |
} |
| ... | ... |
@@ -126,5 +120,5 @@ func main() {
|
| 126 | 126 |
} |
| 127 | 127 |
|
| 128 | 128 |
func showVersion() {
|
| 129 |
- fmt.Printf("Docker version %s, build %s\n", VERSION, GITCOMMIT)
|
|
| 129 |
+ fmt.Printf("Docker version %s, build %s\n", dockerversion.VERSION, dockerversion.GITCOMMIT)
|
|
| 130 | 130 |
} |
| 131 | 131 |
new file mode 100644 |
| ... | ... |
@@ -0,0 +1,11 @@ |
| 0 |
+package dockerversion |
|
| 1 |
+ |
|
| 2 |
+// FIXME: this should be embedded in the docker/docker.go, |
|
| 3 |
+// but we can't because distro policy requires us to |
|
| 4 |
+// package a separate dockerinit binary, and that binary needs |
|
| 5 |
+// to know its version too. |
|
| 6 |
+ |
|
| 7 |
+var ( |
|
| 8 |
+ GITCOMMIT string |
|
| 9 |
+ VERSION string |
|
| 10 |
+) |
| ... | ... |
@@ -82,7 +82,7 @@ if [ ! "$GOPATH" ]; then |
| 82 | 82 |
fi |
| 83 | 83 |
|
| 84 | 84 |
# Use these flags when compiling the tests and final binary |
| 85 |
-LDFLAGS='-X main.GITCOMMIT "'$GITCOMMIT'" -X main.VERSION "'$VERSION'" -w' |
|
| 85 |
+LDFLAGS='-X github.com/dotcloud/docker/dockerversion.GITCOMMIT "'$GITCOMMIT'" -X github.com/dotcloud/docker/dockerversion.VERSION "'$VERSION'" -w' |
|
| 86 | 86 |
LDFLAGS_STATIC='-X github.com/dotcloud/docker/utils.IAMSTATIC true -linkmode external -extldflags "-lpthread -static -Wl,--unresolved-symbols=ignore-in-object-files"' |
| 87 | 87 |
BUILDFLAGS='-tags netgo -a' |
| 88 | 88 |
|
| ... | ... |
@@ -1,11 +1,20 @@ |
| 1 | 1 |
package docker |
| 2 | 2 |
|
| 3 | 3 |
import ( |
| 4 |
+ "github.com/dotcloud/docker/dockerversion" |
|
| 4 | 5 |
"github.com/dotcloud/docker/engine" |
| 5 | 6 |
"github.com/dotcloud/docker/utils" |
| 6 | 7 |
"runtime" |
| 7 | 8 |
) |
| 8 | 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 |
+ |
|
| 9 | 18 |
func init() {
|
| 10 | 19 |
engine.Register("version", jobVersion)
|
| 11 | 20 |
} |