Skip to content

Commit

Permalink
Add build date to version info
Browse files Browse the repository at this point in the history
Used govvv for build time information

Signed-off-by: Barun Acharya <barun.acharya@accuknox.com>
  • Loading branch information
daemon1024 committed Sep 21, 2021
1 parent 9b8dd0e commit 1d41ba9
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
CURDIR=$(shell pwd)
VERSION=$(shell git describe --tags --dirty --always)

ifeq (,$(shell which govvv))
$(shell go install github.com/ahmetb/govvv@latest)
endif

PKG := $(shell go list ./version)
GIT_INFO := $(shell govvv -flags -pkg $(PKG))

.PHONY: build
build:
cd $(CURDIR)
go mod tidy
CGO_ENABLED=0 go build \
-ldflags "-w -s -X github.com/kubearmor/kubearmor-client/version.version=${VERSION}" \
-ldflags "-w -s ${GIT_INFO}" \
-o karmor
5 changes: 3 additions & 2 deletions version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,11 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var version string
var GitSummary string
var BuildDate string

func PrintVersion(c *k8s.Client) error {
fmt.Printf("karmor version %s %s/%s\n", version, runtime.GOOS, runtime.GOARCH)
fmt.Printf("karmor version %s %s/%s BuildDate=%s\n", GitSummary, runtime.GOOS, runtime.GOARCH, BuildDate)
kubearmorVersion, err := getKubeArmorVersion(c)
if err != nil {
return nil
Expand Down

0 comments on commit 1d41ba9

Please sign in to comment.