diff --git a/cmd/helm/version.go b/cmd/helm/version.go index 9c66cea00917114a55ff649b12bf76609c69c6ec..e22d0a800ff3ae13056e153641fe9cc75b6be133 100644 --- a/cmd/helm/version.go +++ b/cmd/helm/version.go @@ -52,12 +52,12 @@ func (v *versionCmd) run() error { // Regardless of whether we can talk to server or not, just print the client // version. cv := version.GetVersionProto() - fmt.Fprintf(v.out, "Client: {SemVer: %s GitCommit: %s}\n", cv.SemVer, cv.GitCommit) + fmt.Fprintf(v.out, "Client: %#v\n", cv) resp, err := v.client.GetVersion() if err != nil { return err } - fmt.Fprintf(v.out, "Server: {SemVer: %s GitCommit: %s}\n", resp.Version.SemVer, resp.Version.GitCommit) + fmt.Fprintf(v.out, "Server: %#v\n", resp.Version) return nil } diff --git a/cmd/tiller/release_server.go b/cmd/tiller/release_server.go index 678570841d2b9ba12a7833879496cffba2a0ea24..3d82677158379019ad7ecfc9d4924e88df5a1877 100644 --- a/cmd/tiller/release_server.go +++ b/cmd/tiller/release_server.go @@ -178,7 +178,7 @@ func filterReleases(filter string, rels []*release.Release) ([]*release.Release, func (s *releaseServer) GetVersion(c ctx.Context, req *services.GetVersionRequest) (*services.GetVersionResponse, error) { v := version.GetVersionProto() - return &services.GetVersionResponse{Version: &v}, nil + return &services.GetVersionResponse{Version: v}, nil } func (s *releaseServer) GetReleaseStatus(c ctx.Context, req *services.GetReleaseStatusRequest) (*services.GetReleaseStatusResponse, error) { diff --git a/pkg/helm/client.go b/pkg/helm/client.go index ce08bd6b18c3b3df84d733419fb88ebb4513c876..bf55562a081115f6004bb645f4b31dd82f890959 100644 --- a/pkg/helm/client.go +++ b/pkg/helm/client.go @@ -120,7 +120,7 @@ func (h *Client) UpdateRelease(rlsName string, chStr string, opts ...UpdateOptio return h.opts.rpcUpdateRelease(rlsName, chart, rls.NewReleaseServiceClient(c), opts...) } -// Version returns the server version +// GetVersion returns the server version // // Note: there aren't currently any supported StatusOptions, // but they are kept in the API signature as a placeholder for future additions. diff --git a/pkg/version/version.go b/pkg/version/version.go index ba36c3d4ccec2503a7f3406d9cd53830b3161936..eb96bd7c8a29091d56ea3ab938d80d727b133548 100644 --- a/pkg/version/version.go +++ b/pkg/version/version.go @@ -17,26 +17,27 @@ limitations under the License. // Package version represents the current version of the project. package version // import "k8s.io/helm/pkg/version" -import ( - "k8s.io/helm/pkg/proto/hapi/version" +import "k8s.io/helm/pkg/proto/hapi/version" + +var ( + // Version is the current version of the Helm. + // Update this whenever making a new release. + // The version is of the format Major.Minor.Patch[-Prerelease][+BuildMetadata] + // + // Increment major number for new feature additions and behavioral changes. + // Increment minor number for bug fixes and performance enhancements. + // Increment patch number for critical fixes to existing releases. + Version = "v2.0.0-alpha.4" + + // BuildMetadata is extra build time data + BuildMetadata = "" + // GitCommit is the git sha1 + GitCommit = "" + // GitTreeState is the state of the git tree + GitTreeState = "" ) -// Version is the current version of the Helm. -// Update this whenever making a new release. -// The version is of the format Major.Minor.Patch[-Prerelease][+BuildMetadata] -// -// Increment major number for new feature additions and behavioral changes. -// Increment minor number for bug fixes and performance enhancements. -// Increment patch number for critical fixes to existing releases. -// -// BuildMetadata gets filled in during build, do not touch -// GitCommit gets filled in during build, do not touch -var Version = "v2.0.0-alpha.4" -var BuildMetadata = "" -var GitCommit = "" - // GetVersion returns the semver string of the version - func GetVersion() string { if BuildMetadata == "" { return Version @@ -45,9 +46,10 @@ func GetVersion() string { } // GetVersionProto returns protobuf representing the version -func GetVersionProto() version.Version { - return version.Version{ - SemVer: GetVersion(), - GitCommit: GitCommit, +func GetVersionProto() *version.Version { + return &version.Version{ + SemVer: GetVersion(), + GitCommit: GitCommit, + GitTreeState: GitTreeState, } } diff --git a/versioning.mk b/versioning.mk index 94f3ceaa807cb38e9b7551f3fe05dcddb2dee7b1..4825c4e729738ba707fdbefe0ede8913f44be774 100644 --- a/versioning.mk +++ b/versioning.mk @@ -3,6 +3,7 @@ MUTABLE_VERSION ?= canary GIT_COMMIT := $(shell git rev-parse HEAD) GIT_SHA := $(shell git rev-parse --short HEAD) GIT_TAG := $(shell git describe --tags --abbrev=0 2>/dev/null) +GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean") ifdef VERSION DOCKER_VERSION = $(VERSION) @@ -15,8 +16,9 @@ BINARY_VERSION ?= ${GIT_TAG}-${GIT_SHA} IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${SHORT_NAME}:${DOCKER_VERSION} MUTABLE_IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${SHORT_NAME}:${MUTABLE_VERSION} -LDFLAGS += -X k8s.io/helm/pkg/version.SemVer=${GIT_TAG} +LDFLAGS += -X k8s.io/helm/pkg/version.Version=${GIT_TAG} LDFLAGS += -X k8s.io/helm/pkg/version.GitCommit=${GIT_COMMIT} +LDFLAGS += -X k8s.io/helm/pkg/version.GitTreeState=${GIT_DIRTY} DOCKER_PUSH = docker push ifeq ($(DOCKER_REGISTRY),gcr.io)