From 722c7424d0f11e9177558e014e4671fb2f5d9602 Mon Sep 17 00:00:00 2001 From: Patrice Ferlet Date: Mon, 14 Feb 2022 17:15:11 +0100 Subject: [PATCH] Fix version flag --- Makefile | 5 +++-- cmd/main.go | 15 ++++++++------- main.go | 7 ++++++- 3 files changed, 17 insertions(+), 10 deletions(-) diff --git a/Makefile b/Makefile index 9217c0f..19f6091 100644 --- a/Makefile +++ b/Makefile @@ -38,8 +38,8 @@ else @echo "=> Build in container using" $(CTN) @echo endif -ifeq ($(GO),local) echo $(BLD_CMD) +ifeq ($(GO),local) $(BLD_CMD) else ifeq ($(CTN),podman) @podman run --rm -v $(PWD):/go/src/katenary:z -w /go/src/katenary --userns keep-id -it golang $(BLD_CMD) @@ -48,7 +48,8 @@ else endif echo echo "Check the version" - echo "'./katenary version' => $(shell ./katenary version)" + echo -n "'./katenary version' => "; ./katenary version + echo install: build diff --git a/cmd/main.go b/cmd/main.go index c758dcb..421f38b 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -11,13 +11,14 @@ import ( "strings" ) -var composeFiles = []string{"docker-compose.yaml", "docker-compose.yml"} -var ComposeFile = "" -var AppName = "MyApp" -var Version = "master" // set at build time to the git version/tag -var ChartsDir = "chart" - -var AppVersion = "0.0.1" +var ( + composeFiles = []string{"docker-compose.yaml", "docker-compose.yml"} + ComposeFile = "" + AppName = "MyApp" + ChartsDir = "chart" + Version = "master" + AppVersion = "0.0.1" +) func init() { FindComposeFile() diff --git a/main.go b/main.go index 1deb50e..ba128ac 100644 --- a/main.go +++ b/main.go @@ -7,7 +7,8 @@ import ( "github.com/spf13/cobra" ) -var Version = "master" // set at build time to the git version/tag +var Version = "master" // changed at compile time + var longHelp = `Katenary aims to be a tool to convert docker-compose files to Helm Charts. It will create deployments, services, volumes, secrets, and ingress resources. But it will also create initContainers based on depend_on, healthcheck, and other features. @@ -25,6 +26,10 @@ or ` func main() { + + // set the version to "cmd" package - yes... it's ugly + cmd.Version = Version + // The base command rootCmd := &cobra.Command{ Use: "katenary",