From db25ac446acd5b3a08c83bdebe52cb346814961b Mon Sep 17 00:00:00 2001 From: 06kellyjac Date: Thu, 16 Jun 2022 12:49:58 +0100 Subject: [PATCH] Clarify arch is the builder and pull go ver from runtime --- Makefile | 6 ++---- commands/version.go | 13 ++++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/Makefile b/Makefile index c4fbaf6..8fba88c 100644 --- a/Makefile +++ b/Makefile @@ -1,8 +1,7 @@ CMDPACKAGE=github.com/quarkslab/kdigger/commands VERSION=$$(git describe --tags 2>/dev/null || echo dev) GITCOMMIT=$$(git rev-parse HEAD) -GOVERSION=$$(go version | awk '{print $$3}') -ARCH=$$(uname -m) +BUILDERARCH=$$(uname -m) OUTPUTNAME=kdigger @@ -20,8 +19,7 @@ GOARCH=amd64 LDFLAGS="-s -w \ -X $(CMDPACKAGE).VERSION=$(VERSION) \ -X $(CMDPACKAGE).GITCOMMIT=$(GITCOMMIT) \ - -X $(CMDPACKAGE).GOVERSION=$(GOVERSION) \ - -X $(CMDPACKAGE).ARCH=$(ARCH)" + -X $(CMDPACKAGE).BUILDERARCH=$(BUILDERARCH)" # if CGO_ENABLED=1, the binary will be dynamically linked, and surprisingly, # bigger! It seems that it is because of the net package that Go is dynamically diff --git a/commands/version.go b/commands/version.go index dbdf5ba..f1006f6 100644 --- a/commands/version.go +++ b/commands/version.go @@ -1,6 +1,8 @@ package commands import ( + "runtime" + "github.com/quarkslab/kdigger/pkg/bucket" "github.com/spf13/cobra" ) @@ -11,11 +13,8 @@ var VERSION string // GITCOMMIT indicates which git hash the binary was built off of var GITCOMMIT string -// GOVERSION indicates the golang version the binary was built with -var GOVERSION string - -// ARCH indicates the arch the binary was built on -var ARCH string +// BUILDERARCH indicates the arch the binary was built on +var BUILDERARCH string // versionCmd represents the version command var versionCmd = &cobra.Command{ @@ -26,8 +25,8 @@ var versionCmd = &cobra.Command{ RunE: func(cmd *cobra.Command, args []string) error { // leveraging bucket results to print even if it's not a plugin res := bucket.NewResults("Version") - res.SetHeaders([]string{"tag", "gitCommit", "goVersion", "architecture"}) - res.AddContent([]interface{}{VERSION, GITCOMMIT, GOVERSION, ARCH}) + res.SetHeaders([]string{"tag", "gitCommit", "goVersion", "builderArch"}) + res.AddContent([]interface{}{VERSION, GITCOMMIT, runtime.Version(), BUILDERARCH}) showName := false showComment := false