diff --git a/KPOD_VERSION b/KPOD_VERSION new file mode 100644 index 00000000..ceab6e11 --- /dev/null +++ b/KPOD_VERSION @@ -0,0 +1 @@ +0.1 \ No newline at end of file diff --git a/Makefile b/Makefile index f4a9fae3..b6d926ab 100644 --- a/Makefile +++ b/Makefile @@ -20,6 +20,7 @@ GIT_COMMIT := $(if $(shell git status --porcelain --untracked-files=no),"${COMMI BUILD_INFO := $(shell date +%s) VERSION := ${shell cat ./VERSION} +KPOD_VERSION := ${shell cat ./KPOD_VERSION} # If GOPATH not specified, use one in the local directory ifeq ($(GOPATH),) @@ -32,7 +33,7 @@ GOPKGBASEDIR := $(shell dirname "$(GOPKGDIR)") # Update VPATH so make finds .gopathok VPATH := $(VPATH):$(GOPATH) -LDFLAGS := -ldflags '-X main.gitCommit=${GIT_COMMIT} -X main.buildInfo=${BUILD_INFO} -X main.version=${VERSION}' +LDFLAGS := -ldflags '-X main.gitCommit=${GIT_COMMIT} -X main.buildInfo=${BUILD_INFO} -X main.version=${VERSION} -X main.kpodVersion=${KPOD_VERSION}' all: binaries crio.conf docs diff --git a/cmd/kpod/info.go b/cmd/kpod/info.go index d641a7e0..b5400e93 100644 --- a/cmd/kpod/info.go +++ b/cmd/kpod/info.go @@ -85,6 +85,8 @@ func debugInfo(c *cli.Context) (string, map[string]interface{}, error) { info := map[string]interface{}{} info["compiler"] = runtime.Compiler info["go version"] = runtime.Version() + info["kpod version"] = c.App.Version + info["git commit"] = gitCommit return "debug", info, nil } diff --git a/cmd/kpod/main.go b/cmd/kpod/main.go index 2a51aa28..d5be45e9 100644 --- a/cmd/kpod/main.go +++ b/cmd/kpod/main.go @@ -8,6 +8,10 @@ import ( "github.com/urfave/cli" ) +// This is populated by the Makefile from the VERSION file +// in the repository +var kpodVersion = "" + func main() { if reexec.Init() { return @@ -16,7 +20,12 @@ func main() { app := cli.NewApp() app.Name = "kpod" app.Usage = "manage pods and images" - app.Version = "0.0.1" + + var v string + if kpodVersion != "" { + v = kpodVersion + } + app.Version = v app.Commands = []cli.Command{ diffCommand, diff --git a/cmd/kpod/version.go b/cmd/kpod/version.go index 9680c900..586c41da 100644 --- a/cmd/kpod/version.go +++ b/cmd/kpod/version.go @@ -11,7 +11,11 @@ import ( // Overwritten at build time var ( + // gitCommit is the commit that the binary is being built from. + // It will be populated by the Makefile. gitCommit string + // buildInfo is the time at which the binary was built + // It will be populated by the Makefile. buildInfo string )