diff --git a/Makefile b/Makefile index 990e5722..bef55b13 100644 --- a/Makefile +++ b/Makefile @@ -3,7 +3,6 @@ SHELL = bash REPO ?= $(shell go list -m) VERSION ?= $(shell git describe --tags --dirty --always 2>/dev/null || cat VERSION 2>/dev/null || echo "develop") -BUILD ?= $(shell date -u --iso=seconds) DEBUG ?= false HUB_IMAGE ?= nspccdev/neofs @@ -36,7 +35,6 @@ $(BINS): $(DIRS) dep CGO_ENABLED=0 \ go build -v -trimpath \ -ldflags "-X $(REPO)/misc.Version=$(VERSION) \ - -X $(REPO)/misc.Build=$(BUILD) \ -X $(REPO)/misc.Debug=$(DEBUG)" \ -o $@ ./cmd/$(notdir $@) diff --git a/cmd/neofs-adm/internal/modules/root.go b/cmd/neofs-adm/internal/modules/root.go index 2234fc3d..5c2cde67 100644 --- a/cmd/neofs-adm/internal/modules/root.go +++ b/cmd/neofs-adm/internal/modules/root.go @@ -1,7 +1,6 @@ package modules import ( - "fmt" "os" "github.com/nspcc-dev/neofs-node/cmd/neofs-adm/internal/modules/config" @@ -53,11 +52,7 @@ func Execute() error { func entryPoint(cmd *cobra.Command, args []string) error { printVersion, err := cmd.Flags().GetBool("version") if err == nil && printVersion { - fmt.Printf("Version: %s \nBuild: %s \nDebug: %s\n", - misc.Version, - misc.Build, - misc.Debug, - ) + cmd.Print(misc.BuildInfo("NeoFS Adm")) return nil } diff --git a/cmd/neofs-cli/modules/root.go b/cmd/neofs-cli/modules/root.go index 1f1f2b44..8191ac39 100644 --- a/cmd/neofs-cli/modules/root.go +++ b/cmd/neofs-cli/modules/root.go @@ -87,12 +87,7 @@ func init() { func entryPoint(cmd *cobra.Command, _ []string) { printVersion, _ := cmd.Flags().GetBool("version") if printVersion { - cmd.Printf( - "Version: %s \nBuild: %s \nDebug: %s\n", - misc.Version, - misc.Build, - misc.Debug, - ) + cmd.Print(misc.BuildInfo("NeoFS CLI")) return } diff --git a/cmd/neofs-ir/main.go b/cmd/neofs-ir/main.go index 3c2105b7..824bef41 100644 --- a/cmd/neofs-ir/main.go +++ b/cmd/neofs-ir/main.go @@ -39,12 +39,7 @@ func main() { flag.Parse() if *versionFlag { - fmt.Printf( - "Version: %s \nBuild: %s \nDebug: %s\n", - misc.Version, - misc.Build, - misc.Debug, - ) + fmt.Print(misc.BuildInfo("NeoFS Inner Ring node")) os.Exit(SuccessReturnCode) } @@ -85,7 +80,6 @@ func main() { exitErr(err) log.Info("application started", - zap.String("build_time", misc.Build), zap.String("version", misc.Version), zap.String("debug", misc.Debug), ) diff --git a/cmd/neofs-lens/root.go b/cmd/neofs-lens/root.go index 8cfdd9c3..b82df64f 100644 --- a/cmd/neofs-lens/root.go +++ b/cmd/neofs-lens/root.go @@ -1,7 +1,6 @@ package main import ( - "fmt" "os" "github.com/nspcc-dev/neofs-node/cmd/neofs-lens/internal/commands/inspect" @@ -22,11 +21,8 @@ var command = &cobra.Command{ func entryPoint(cmd *cobra.Command, _ []string) error { printVersion, err := cmd.Flags().GetBool("version") if err == nil && printVersion { - fmt.Printf("Version: %s \nBuild: %s \nDebug: %s\n", - misc.Version, - misc.Build, - misc.Debug, - ) + cmd.Print(misc.BuildInfo("NeoFS Lens")) + return nil } diff --git a/cmd/neofs-node/main.go b/cmd/neofs-node/main.go index a38eec6b..74440ea6 100644 --- a/cmd/neofs-node/main.go +++ b/cmd/neofs-node/main.go @@ -39,12 +39,7 @@ func main() { flag.Parse() if *versionFlag { - fmt.Printf( - "Version: %s \nBuild: %s \nDebug: %s\n", - misc.Version, - misc.Build, - misc.Debug, - ) + fmt.Print(misc.BuildInfo("NeoFS Storage node")) os.Exit(SuccessReturnCode) } @@ -115,7 +110,6 @@ func bootUp(c *cfg) { func wait(c *cfg) { c.log.Info("application started", - zap.String("build_time", misc.Build), zap.String("version", misc.Version), zap.String("debug", misc.Debug), ) diff --git a/misc/build.go b/misc/build.go index 198c4a43..710229df 100644 --- a/misc/build.go +++ b/misc/build.go @@ -1,13 +1,25 @@ package misc +import ( + "fmt" + "runtime" +) + // These variables are changed in compile time. var ( - // Build is an application build time. - Build = "now" - // Version is an application version. Version = "dev" // Debug is an application debug mode flag. Debug = "false" ) + +// BuildInfo returns human-readable information about this binary. +func BuildInfo(component string) string { + return fmt.Sprintf("%s\nVersion: %s \nGoVersion: %s\nDebug: %s\n", + component, + Version, + runtime.Version(), + Debug, + ) +}