Commit 264c6b10 authored by Adam Reese's avatar Adam Reese

feat(*): add git tree state to binaries

* clean up version output
parent 1d6202d8
......@@ -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
}
......@@ -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) {
......
......@@ -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.
......
......@@ -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,
}
}
......@@ -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)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment