File tree 2 files changed +18
-2
lines changed
2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -8,6 +8,8 @@ OS ?= $(shell go env GOOS)
8
8
ARCH ?= $(shell go env GOARCH)
9
9
BIN_NAME ?= observatorium-api
10
10
FILES_TO_FMT ?= $(filter-out ./ratelimit/gubernator/gubernator.pb.go, $(shell find . -path ./vendor -not -prune -o -name '* .go' -print) )
11
+ GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
12
+ GIT_REVISION := $(shell git rev-parse --short HEAD)
11
13
12
14
VERSION := $(strip $(shell [ -d .git ] && git describe --always --tags --dirty) )
13
15
BUILD_DATE := $(shell date -u +"% Y-% m-% d")
@@ -79,7 +81,7 @@ benchmark.md: $(EMBEDMD) tmp/load_help.txt
79
81
$(EMBEDMD ) -w docs/benchmark.md
80
82
81
83
$(BIN_NAME ) : deps main.go rules/rules.go $(wildcard * .go) $(wildcard * /* .go)
82
- CGO_ENABLED=0 GOOS=$(OS ) GOARCH=$(ARCH ) GO111MODULE=on GOPROXY=https://proxy.golang.org go build -a -ldflags ' -s -w' -o $(BIN_NAME ) .
84
+ CGO_ENABLED=0 GOOS=$(OS ) GOARCH=$(ARCH ) GO111MODULE=on GOPROXY=https://proxy.golang.org go build -a -ldflags ' -s -w -X main.Version=$(VERSION) -X main.Branch=$(GIT_BRANCH) -X main.Revision=$(GIT_REVISION) ' -o $(BIN_NAME ) .
83
85
84
86
% .y.go : % .y | $(GOYACC )
85
87
$(GOYACC ) -p $(basename $(notdir $< ) ) -o $@ $<
Original file line number Diff line number Diff line change @@ -82,6 +82,13 @@ const (
82
82
gracePeriod = 2 * time .Minute
83
83
)
84
84
85
+ // Version is set via build flag -ldflags -X main.Version.
86
+ var (
87
+ Version string
88
+ Branch string
89
+ Revision string
90
+ )
91
+
85
92
type config struct {
86
93
logLevel string
87
94
logFormat string
@@ -258,13 +265,21 @@ type tenant struct {
258
265
} `json:"rateLimits"`
259
266
}
260
267
268
+ func init () {
269
+ version .Version = Version
270
+ version .Branch = Branch
271
+ version .Revision = Revision
272
+ }
273
+
261
274
//nolint:funlen,gocyclo,gocognit
262
275
func main () {
263
276
cfg , err := parseFlags ()
264
277
if err != nil {
265
278
stdlog .Fatalf ("parse flag: %v" , err )
266
279
}
267
280
281
+ stdlog .Println (version .Info ())
282
+
268
283
if ! cfg .metrics .enabled && ! cfg .logs .enabled && ! cfg .traces .enabled {
269
284
stdlog .Fatal ("Neither logging, metrics not traces endpoints are enabled. " +
270
285
"Specifying at least a logging or a metrics endpoint is mandatory" )
@@ -1018,7 +1033,6 @@ func parseFlags() (config, error) {
1018
1033
)
1019
1034
1020
1035
cfg := config {}
1021
-
1022
1036
flag .StringVar (& cfg .rbacConfigPath , "rbac.config" , "rbac.yaml" ,
1023
1037
"Path to the RBAC configuration file." )
1024
1038
flag .StringVar (& cfg .tenantsConfigPath , "tenants.config" , "tenants.yaml" ,
You can’t perform that action at this time.
0 commit comments