Skip to content

Commit

Permalink
Merge pull request #2 from 06kellyjac/version_tweaks
Browse files Browse the repository at this point in the history
Clarify arch is the builder and pull go ver from runtime
  • Loading branch information
mtardy authored Jun 16, 2022
2 parents 1817e59 + db25ac4 commit 96ccb9d
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
6 changes: 2 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand All @@ -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
Expand Down
13 changes: 6 additions & 7 deletions commands/version.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package commands

import (
"runtime"

"github.com/quarkslab/kdigger/pkg/bucket"
"github.com/spf13/cobra"
)
Expand All @@ -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{
Expand All @@ -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
Expand Down

0 comments on commit 96ccb9d

Please # to comment.