Skip to content

Commit

Permalink
BUG | Fix Version display
Browse files Browse the repository at this point in the history
The version is not display like accepted
This will fix it

Signed-off-by: Manuel Müller <mueller.m.h@gmail.com>
  • Loading branch information
MuellerMH committed Oct 23, 2018
1 parent e90a384 commit ad7444f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
6 changes: 4 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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
Expand Down
10 changes: 2 additions & 8 deletions cmd/cli/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 + ")")
},
}

Expand Down
8 changes: 7 additions & 1 deletion pkg/common/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit ad7444f

Please sign in to comment.