From c8e2b0d8754726d447c0c6ac7d8d2870a309759d Mon Sep 17 00:00:00 2001 From: Aaron Schlesinger Date: Wed, 1 Jun 2016 09:47:39 -0700 Subject: [PATCH] Add release version for the Helm CLI Fixes https://github.com/kubernetes/helm/issues/761 --- Makefile | 4 +++- cmd/helm/version.go | 37 +++++++++++++++++++++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 cmd/helm/version.go diff --git a/Makefile b/Makefile index ab5ba4e4d..407ef7916 100644 --- a/Makefile +++ b/Makefile @@ -2,13 +2,15 @@ DOCKER_REGISTRY ?= gcr.io IMAGE_PREFIX ?= kubernetes-helm SHORT_NAME ?= tiller +CLI_VERSION ?= devel + # go option GO ?= go PKG := $(shell glide novendor) TAGS := TESTS := . TESTFLAGS := -LDFLAGS := +LDFLAGS := "-X cmd.helm.cliVersion ${CLI_VERSION}" GOFLAGS := BINDIR := $(CURDIR)/bin BINARIES := helm tiller diff --git a/cmd/helm/version.go b/cmd/helm/version.go new file mode 100644 index 000000000..ee79b6d21 --- /dev/null +++ b/cmd/helm/version.go @@ -0,0 +1,37 @@ +package main + +import ( + "errors" + "fmt" + "strings" + + "github.com/gosuri/uitable" + "github.com/kubernetes/helm/pkg/helm" + "github.com/kubernetes/helm/pkg/proto/hapi/release" + "github.com/kubernetes/helm/pkg/proto/hapi/services" + "github.com/kubernetes/helm/pkg/timeconv" + "github.com/spf13/cobra" +) + +var ( + versionHelp = "This command prints out the current version of the Helm CLI." + // this variable is set by the Makefile, using the Go linker flags + cliVersion = "devel" +) + +var versionCommand = &cobra.Command{ + Use: "version", + Short: "Get the current version of Helm", + Long: versionHelp, + RunE: versionCmd, + Aliases: []string{"vsn"}, +} + +func init() { + RootCommand.AddCommand(versionCommand) +} + +func versionCmd(cmd *cobra.Command, args []string) error { + fmt.Println("Helm CLI version", cliVersion) + return nil +}