From 2cd32484317a382a6121ef33ff1c52c7ea8bd01e Mon Sep 17 00:00:00 2001 From: j-k Date: Mon, 14 Mar 2022 10:29:34 +0000 Subject: [PATCH] refactor: use runtime rather than ldflags for go details (#1302) --- Makefile | 4 +--- pkg/cwversion/version.go | 13 +++++++------ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Makefile b/Makefile index eb07b91ad..7a2a1cc8f 100644 --- a/Makefile +++ b/Makefile @@ -50,11 +50,9 @@ DEFAULT_DATADIR ?= "/var/lib/crowdsec/data" LD_OPTS_VARS= \ -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version=$(BUILD_VERSION) \ --X github.com/crowdsecurity/crowdsec/pkg/cwversion.System=$(SYSTEM) \ -X github.com/crowdsecurity/crowdsec/pkg/cwversion.BuildDate=$(BUILD_TIMESTAMP) \ --X github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=$(BUILD_CODENAME) \ +-X github.com/crowdsecurity/crowdsec/pkg/cwversion.Codename=$(BUILD_CODENAME) \ -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Tag=$(BUILD_TAG) \ --X github.com/crowdsecurity/crowdsec/pkg/cwversion.GoVersion=$(BUILD_GOVERSION) \ -X github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultConfigDir=$(DEFAULT_CONFIGDIR) \ -X github.com/crowdsecurity/crowdsec/pkg/csconfig.defaultDataDir=$(DEFAULT_DATADIR) diff --git a/pkg/cwversion/version.go b/pkg/cwversion/version.go index 54fe2739e..4470b9132 100644 --- a/pkg/cwversion/version.go +++ b/pkg/cwversion/version.go @@ -5,6 +5,7 @@ import ( "fmt" "log" "net/http" + "runtime" "strings" version "github.com/hashicorp/go-version" @@ -23,12 +24,12 @@ Additional labels for pre-release and build metadata are available as extensions */ var ( - Version string // = "v0.0.0" - Codename string // = "SoumSoum" - BuildDate string // = "I don't remember exactly" - Tag string // = "dev" - GoVersion string // = "1.13" - System string // = "linux" + Version string // = "v0.0.0" + Codename string // = "SoumSoum" + BuildDate string // = "0000-00-00_00:00:00" + Tag string // = "dev" + GoVersion = runtime.Version()[2:] // = "1.13" + System = runtime.GOOS // = "linux" Constraint_parser = ">= 1.0, <= 2.0" Constraint_scenario = ">= 1.0, < 3.0" Constraint_api = "v1"