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 { ...@@ -52,12 +52,12 @@ func (v *versionCmd) run() error {
// Regardless of whether we can talk to server or not, just print the client // Regardless of whether we can talk to server or not, just print the client
// version. // version.
cv := version.GetVersionProto() 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() resp, err := v.client.GetVersion()
if err != nil { if err != nil {
return err 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 return nil
} }
...@@ -178,7 +178,7 @@ func filterReleases(filter string, rels []*release.Release) ([]*release.Release, ...@@ -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) { func (s *releaseServer) GetVersion(c ctx.Context, req *services.GetVersionRequest) (*services.GetVersionResponse, error) {
v := version.GetVersionProto() 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) { 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 ...@@ -120,7 +120,7 @@ func (h *Client) UpdateRelease(rlsName string, chStr string, opts ...UpdateOptio
return h.opts.rpcUpdateRelease(rlsName, chart, rls.NewReleaseServiceClient(c), opts...) 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, // Note: there aren't currently any supported StatusOptions,
// but they are kept in the API signature as a placeholder for future additions. // but they are kept in the API signature as a placeholder for future additions.
......
...@@ -17,26 +17,27 @@ limitations under the License. ...@@ -17,26 +17,27 @@ limitations under the License.
// Package version represents the current version of the project. // Package version represents the current version of the project.
package version // import "k8s.io/helm/pkg/version" package version // import "k8s.io/helm/pkg/version"
import ( import "k8s.io/helm/pkg/proto/hapi/version"
"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 // GetVersion returns the semver string of the version
func GetVersion() string { func GetVersion() string {
if BuildMetadata == "" { if BuildMetadata == "" {
return Version return Version
...@@ -45,9 +46,10 @@ func GetVersion() string { ...@@ -45,9 +46,10 @@ func GetVersion() string {
} }
// GetVersionProto returns protobuf representing the version // GetVersionProto returns protobuf representing the version
func GetVersionProto() version.Version { func GetVersionProto() *version.Version {
return version.Version{ return &version.Version{
SemVer: GetVersion(), SemVer: GetVersion(),
GitCommit: GitCommit, GitCommit: GitCommit,
GitTreeState: GitTreeState,
} }
} }
...@@ -3,6 +3,7 @@ MUTABLE_VERSION ?= canary ...@@ -3,6 +3,7 @@ MUTABLE_VERSION ?= canary
GIT_COMMIT := $(shell git rev-parse HEAD) GIT_COMMIT := $(shell git rev-parse HEAD)
GIT_SHA := $(shell git rev-parse --short HEAD) GIT_SHA := $(shell git rev-parse --short HEAD)
GIT_TAG := $(shell git describe --tags --abbrev=0 2>/dev/null) 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 ifdef VERSION
DOCKER_VERSION = $(VERSION) DOCKER_VERSION = $(VERSION)
...@@ -15,8 +16,9 @@ BINARY_VERSION ?= ${GIT_TAG}-${GIT_SHA} ...@@ -15,8 +16,9 @@ BINARY_VERSION ?= ${GIT_TAG}-${GIT_SHA}
IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${SHORT_NAME}:${DOCKER_VERSION} IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${SHORT_NAME}:${DOCKER_VERSION}
MUTABLE_IMAGE := ${DOCKER_REGISTRY}/${IMAGE_PREFIX}/${SHORT_NAME}:${MUTABLE_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.GitCommit=${GIT_COMMIT}
LDFLAGS += -X k8s.io/helm/pkg/version.GitTreeState=${GIT_DIRTY}
DOCKER_PUSH = docker push DOCKER_PUSH = docker push
ifeq ($(DOCKER_REGISTRY),gcr.io) 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