Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clarify arch is the builder and pull go ver from runtime #2

Merged
merged 1 commit into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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