From ad7444f7e730945303287da5a8db39dcacbeb499 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Manuel=20M=C3=BCller?= Date: Tue, 23 Oct 2018 08:45:28 +0200 Subject: [PATCH] BUG | Fix Version display MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The version is not display like accepted This will fix it Signed-off-by: Manuel Müller --- Makefile | 6 ++++-- cmd/cli/version.go | 10 ++-------- pkg/common/main.go | 8 +++++++- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 145f511..50fbe68 100644 --- a/Makefile +++ b/Makefile @@ -1,13 +1,15 @@ PROJECT := github.com/kubernauts/tk8 VERSION := $(shell git tag 2>/dev/null|tail -n 1) GITCOMMIT := $(shell git rev-parse --short HEAD 2>/dev/null) -BUILD_FLAGS := -ldflags="-w -X $(PROJECT)/cmd.GITCOMMIT=$(GITCOMMIT) -X $(PROJECT)/cmd.VERSION=$(VERSION)" +BUILD_FLAGS := -ldflags "-w -s -X $(PROJECT)/pkg/common.GITCOMMIT=$(GITCOMMIT) -X $(PROJECT)/pkg/common.VERSION=$(VERSION)" + + default: bin .PHONY: bin bin: - go get -u ./... + # go get -u ./... go build ${BUILD_FLAGS} -o tk8 main.go .PHONY: install diff --git a/cmd/cli/version.go b/cmd/cli/version.go index 9fa7ff8..6f20f46 100644 --- a/cmd/cli/version.go +++ b/cmd/cli/version.go @@ -17,23 +17,17 @@ package cmd import ( "fmt" + "github.com/kubernauts/tk8/pkg/common" "github.com/spf13/cobra" ) -var ( - // GITCOMMIT will hold the commit SHA to be used in the version command. - GITCOMMIT string - // VERSION will hold the version number to be used in the version command. - VERSION = "dev-build" -) - var versionCmd = &cobra.Command{ Use: "version", Short: "Print the version of TK8", Long: `All software has versions. This is TK8's`, Run: func(cmd *cobra.Command, args []string) { - fmt.Println("Version:" + VERSION + " (Build: " + GITCOMMIT + ")") + fmt.Println("Version:" + common.VERSION + " (Build: " + common.GITCOMMIT + ")") }, } diff --git a/pkg/common/main.go b/pkg/common/main.go index fe8cc5e..242afa5 100644 --- a/pkg/common/main.go +++ b/pkg/common/main.go @@ -8,7 +8,13 @@ import ( "path/filepath" ) -var Name string +var ( + Name string + // GITCOMMIT will hold the commit SHA to be used in the version command. + GITCOMMIT = "0" + // VERSION will hold the version number to be used in the version command. + VERSION = "dev" +) // ErrorCheck is responsbile to check if there is any error returned by a command. func ErrorCheck(msg string, err error) {