add System to cwversion to know platform, add it in UA (#763)

This commit is contained in:
Thibault "bui" Koechlin 2021-04-23 15:23:46 +02:00 committed by GitHub
parent 5e2412cc5d
commit b0d4744b15
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 3 deletions

View file

@ -8,7 +8,7 @@ RUN apk add --no-cache git jq gcc libc-dev make bash gettext
COPY . . COPY . .
RUN BUILD_VERSION="$(git describe --tags `git rev-list --tags --max-count=1`)-docker" make release RUN SYSTEM="docker" make release
RUN /bin/bash wizard.sh --docker-mode RUN /bin/bash wizard.sh --docker-mode
RUN cscli hub update && cscli collections install crowdsecurity/linux RUN cscli hub update && cscli collections install crowdsecurity/linux

View file

@ -1,5 +1,5 @@
ROOT= $(shell git rev-parse --show-toplevel) ROOT= $(shell git rev-parse --show-toplevel)
SYSTEM = $(shell uname -s | tr '[A-Z]' '[a-z]') SYSTEM?= $(shell uname -s | tr '[A-Z]' '[a-z]')
ifneq ("$(wildcard $(ROOT)/platform/$(SYSTEM).mk)", "") ifneq ("$(wildcard $(ROOT)/platform/$(SYSTEM).mk)", "")
include $(ROOT)/platform/$(SYSTEM).mk include $(ROOT)/platform/$(SYSTEM).mk
@ -34,6 +34,7 @@ BUILD_CODENAME=$(shell cat RELEASE.json | jq -r .CodeName)
BUILD_TIMESTAMP=$(shell date +%F"_"%T) BUILD_TIMESTAMP=$(shell date +%F"_"%T)
BUILD_TAG="$(shell git rev-parse HEAD)" BUILD_TAG="$(shell git rev-parse HEAD)"
export LD_OPTS=-ldflags "-s -w -X github.com/crowdsecurity/crowdsec/pkg/cwversion.Version=$(BUILD_VERSION) \ export LD_OPTS=-ldflags "-s -w -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.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.Tag=$(BUILD_TAG) \

View file

@ -28,6 +28,7 @@ var (
BuildDate string // = "I don't remember exactly" BuildDate string // = "I don't remember exactly"
Tag string // = "dev" Tag string // = "dev"
GoVersion string // = "1.13" GoVersion string // = "1.13"
System string // = "linux"
Constraint_parser = ">= 1.0, <= 2.0" Constraint_parser = ">= 1.0, <= 2.0"
Constraint_scenario = ">= 1.0, < 3.0" Constraint_scenario = ">= 1.0, < 3.0"
Constraint_api = "v1" Constraint_api = "v1"
@ -40,6 +41,7 @@ func ShowStr() string {
ret += fmt.Sprintf("Codename: %s\n", Codename) ret += fmt.Sprintf("Codename: %s\n", Codename)
ret += fmt.Sprintf("BuildDate: %s\n", BuildDate) ret += fmt.Sprintf("BuildDate: %s\n", BuildDate)
ret += fmt.Sprintf("GoVersion: %s\n", GoVersion) ret += fmt.Sprintf("GoVersion: %s\n", GoVersion)
ret += fmt.Sprintf("Platform: %s\n", System)
return ret return ret
} }
@ -55,7 +57,7 @@ func Show() {
} }
func VersionStr() string { func VersionStr() string {
return fmt.Sprintf("%s-%s", Version, Tag) return fmt.Sprintf("%s-%s-%s", Version, System, Tag)
} }
func VersionStrip() string { func VersionStrip() string {