File tree 2 files changed +12
-4
lines changed
2 files changed +12
-4
lines changed Original file line number Diff line number Diff line change @@ -5,6 +5,8 @@ GO_SRC := dbms_exporter.go $(shell find ${GO_DIRS} -name '*.go')
5
5
CONTAINER_NAME = ncabatoff/dbms_exporter:latest
6
6
FREETDS_VERSION = 1.1.5
7
7
BUILD_CONTAINER_NAME = ncabatoff/dbms_exporter_builder:${FREETDS_VERSION}
8
+ TAG_VERSION ?= $(shell git describe --tags --abbrev=0)
9
+
8
10
# Possible BUILDTAGS settings are postgres, freetds, and odbc.
9
11
DRIVERS = postgres freetds
10
12
# Use make LDFLAGS= if you want to build with tag ODBC.
@@ -14,7 +16,7 @@ all: vet test dbms_exporter
14
16
15
17
# Simple go build
16
18
dbms_exporter : $(GO_SRC )
17
- go build -ldflags ' $(LDFLAGS) -X main.Version=git:$(shell git rev-parse HEAD )' -o dbms_exporter -tags ' $(DRIVERS)' .
19
+ go build -ldflags ' $(LDFLAGS) -X main.Version=$(TAG_VERSION )' -o dbms_exporter -tags ' $(DRIVERS)' .
18
20
19
21
docker : Dockerfile $(GO_SRC )
20
22
docker build --build-arg drivers=" $( DRIVERS) " --build-arg ldflags=" $( LDFLAGS) " -t $(CONTAINER_NAME ) .
24
26
25
27
test :
26
28
go test -v . ./config ./common ./db ./recipes
27
-
29
+
28
30
test-integration :
29
31
tests/test-smoke
30
32
Original file line number Diff line number Diff line change @@ -19,9 +19,11 @@ import (
19
19
"github.com/prometheus/common/log"
20
20
)
21
21
22
- var Version string = "0.0.1"
22
+ // Version is set at build time use ldflags.
23
+ var Version string
23
24
24
25
var (
26
+ version = flag .Bool ("version" , false , "print version and exit" )
25
27
listenAddress = flag .String (
26
28
"web.listen-address" , ":9113" ,
27
29
"Address to listen on for web interface and telemetry." ,
@@ -458,6 +460,10 @@ func main() {
458
460
fmt .Fprintf (os .Stderr , usage )
459
461
}
460
462
flag .Parse ()
463
+ if * version {
464
+ fmt .Printf ("dbms-exporter version %s\n " , Version )
465
+ os .Exit (0 )
466
+ }
461
467
462
468
if * queriesPath == "" {
463
469
log .Fatalf ("-queryfile is a required argument" )
@@ -508,7 +514,7 @@ func main() {
508
514
509
515
var usage = `
510
516
The DATA_SOURCE_NAME enviroment variable specifies connection details. Examples:
511
-
517
+
512
518
Sybase FreeTDS example (driver=freetds):
513
519
compatibility_mode=sybase;user=myuser;pwd=mypassword;server=myhostname
514
520
You can’t perform that action at this time.
0 commit comments