Skip to content

Commit c56dcf2

Browse files
authored
Merge pull request #863 from umohnani8/version
kpod version
2 parents 10b72d8 + 12512e4 commit c56dcf2

File tree

5 files changed

+19
-2
lines changed

5 files changed

+19
-2
lines changed

KPOD_VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ GIT_COMMIT := $(if $(shell git status --porcelain --untracked-files=no),"${COMMI
2020
BUILD_INFO := $(shell date +%s)
2121

2222
VERSION := ${shell cat ./VERSION}
23+
KPOD_VERSION := ${shell cat ./KPOD_VERSION}
2324

2425
# If GOPATH not specified, use one in the local directory
2526
ifeq ($(GOPATH),)
@@ -32,7 +33,7 @@ GOPKGBASEDIR := $(shell dirname "$(GOPKGDIR)")
3233
# Update VPATH so make finds .gopathok
3334
VPATH := $(VPATH):$(GOPATH)
3435

35-
LDFLAGS := -ldflags '-X main.gitCommit=${GIT_COMMIT} -X main.buildInfo=${BUILD_INFO} -X main.version=${VERSION}'
36+
LDFLAGS := -ldflags '-X main.gitCommit=${GIT_COMMIT} -X main.buildInfo=${BUILD_INFO} -X main.version=${VERSION} -X main.kpodVersion=${KPOD_VERSION}'
3637

3738
all: binaries crio.conf docs
3839

cmd/kpod/info.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,8 @@ func debugInfo(c *cli.Context) (string, map[string]interface{}, error) {
8585
info := map[string]interface{}{}
8686
info["compiler"] = runtime.Compiler
8787
info["go version"] = runtime.Version()
88+
info["kpod version"] = c.App.Version
89+
info["git commit"] = gitCommit
8890
return "debug", info, nil
8991
}
9092

cmd/kpod/main.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ import (
88
"github.com/urfave/cli"
99
)
1010

11+
// This is populated by the Makefile from the VERSION file
12+
// in the repository
13+
var kpodVersion = ""
14+
1115
func main() {
1216
if reexec.Init() {
1317
return
@@ -16,7 +20,12 @@ func main() {
1620
app := cli.NewApp()
1721
app.Name = "kpod"
1822
app.Usage = "manage pods and images"
19-
app.Version = "0.0.1"
23+
24+
var v string
25+
if kpodVersion != "" {
26+
v = kpodVersion
27+
}
28+
app.Version = v
2029

2130
app.Commands = []cli.Command{
2231
diffCommand,

cmd/kpod/version.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@ import (
1111

1212
// Overwritten at build time
1313
var (
14+
// gitCommit is the commit that the binary is being built from.
15+
// It will be populated by the Makefile.
1416
gitCommit string
17+
// buildInfo is the time at which the binary was built
18+
// It will be populated by the Makefile.
1519
buildInfo string
1620
)
1721

0 commit comments

Comments
 (0)