Просмотр исходного кода

refactor: use runtime rather than ldflags for go details (#1302)

j-k 3 лет назад
Родитель
Сommit
2cd3248431
2 измененных файлов с 8 добавлено и 9 удалено
  1. 1 3
      Makefile
  2. 7 6
      pkg/cwversion/version.go

+ 1 - 3
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)
 

+ 7 - 6
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"