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

This commit is contained in:
j-k 2022-03-14 10:29:34 +00:00 committed by GitHub
parent 6f68f4056e
commit 2cd3248431
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 9 deletions

View file

@ -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)

View file

@ -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"