From 0ae21a5f08865f7dbade582c74663c4f33975cf5 Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Thu, 7 Sep 2017 11:27:20 -0700 Subject: [PATCH 1/2] Add support for displaying git commit in version Signed-off-by: Mrunal Patel --- cmd/crio/main.go | 18 +++++++++++++++++- cmd/crioctl/main.go | 19 ++++++++++++++++++- 2 files changed, 35 insertions(+), 2 deletions(-) diff --git a/cmd/crio/main.go b/cmd/crio/main.go index acd496e7..cebbd657 100644 --- a/cmd/crio/main.go +++ b/cmd/crio/main.go @@ -23,6 +23,14 @@ import ( "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime" ) +// This is populated by the Makefile from the VERSION file +// in the repository +var version = "" + +// gitCommit is the commit that the binary is being built from. +// It will be populated by the Makefile. +var gitCommit = "" + func validateConfig(config *server.Config) error { switch config.ImageVolumes { case libkpod.ImageVolumesMkdir: @@ -161,9 +169,17 @@ func main() { return } app := cli.NewApp() + + var v []string + if version != "" { + v = append(v, version) + } + if gitCommit != "" { + v = append(v, fmt.Sprintf("commit: %s", gitCommit)) + } app.Name = "crio" app.Usage = "crio server" - app.Version = "1.0.0-beta.0" + app.Version = strings.Join(v, "\n") app.Metadata = map[string]interface{}{ "config": server.DefaultConfig(), } diff --git a/cmd/crioctl/main.go b/cmd/crioctl/main.go index 977694da..247906a9 100644 --- a/cmd/crioctl/main.go +++ b/cmd/crioctl/main.go @@ -5,6 +5,7 @@ import ( "fmt" "net" "os" + "strings" "time" "github.com/sirupsen/logrus" @@ -13,6 +14,14 @@ import ( pb "k8s.io/kubernetes/pkg/kubelet/apis/cri/v1alpha1/runtime" ) +// This is populated by the Makefile from the VERSION file +// in the repository +var version = "" + +// gitCommit is the commit that the binary is being built from. +// It will be populated by the Makefile. +var gitCommit = "" + func getClientConnection(context *cli.Context) (*grpc.ClientConn, error) { conn, err := grpc.Dial(context.GlobalString("connect"), grpc.WithInsecure(), grpc.WithTimeout(context.GlobalDuration("timeout")), grpc.WithDialer(func(addr string, timeout time.Duration) (net.Conn, error) { @@ -65,9 +74,17 @@ func loadContainerConfig(path string) (*pb.ContainerConfig, error) { func main() { app := cli.NewApp() + var v []string + if version != "" { + v = append(v, version) + } + if gitCommit != "" { + v = append(v, fmt.Sprintf("commit: %s", gitCommit)) + } + app.Name = "crioctl" app.Usage = "client for crio" - app.Version = "1.0.0-beta.0" + app.Version = strings.Join(v, "\n") app.Commands = []cli.Command{ podSandboxCommand, From 086aa910d433fd1bfaaaaac5a0fce6ca6b963370 Mon Sep 17 00:00:00 2001 From: Mrunal Patel Date: Thu, 7 Sep 2017 11:27:56 -0700 Subject: [PATCH 2/2] Bump up version to 1.0.0-rc.1 We add a VERSION file and pass the gitCommit and version to the binary builds in the Makefile. Signed-off-by: Mrunal Patel --- Makefile | 4 +++- VERSION | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 VERSION diff --git a/Makefile b/Makefile index 4ce9c6eb..8c21e145 100644 --- a/Makefile +++ b/Makefile @@ -18,6 +18,8 @@ SELINUXOPT ?= $(shell test -x /usr/sbin/selinuxenabled && selinuxenabled && ech GIT_COMMIT := $(shell git rev-parse --short HEAD) BUILD_INFO := $(shell date +%s) +VERSION := ${shell cat ./VERSION} + # If GOPATH not specified, use one in the local directory ifeq ($(GOPATH),) export GOPATH := $(CURDIR)/_output @@ -29,7 +31,7 @@ GOPKGBASEDIR := $(shell dirname "$(GOPKGDIR)") # Update VPATH so make finds .gopathok VPATH := $(VPATH):$(GOPATH) -LDFLAGS := -ldflags '-X main.gitCommit=${GIT_COMMIT} -X main.buildInfo=${BUILD_INFO}' +LDFLAGS := -ldflags '-X main.gitCommit=${GIT_COMMIT} -X main.buildInfo=${BUILD_INFO} -X main.version=${VERSION}' all: binaries crio.conf docs diff --git a/VERSION b/VERSION new file mode 100644 index 00000000..867bf6ba --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +1.0.0-rc1