Skip to content

Commit

Permalink
manage git tag versioned releases
Browse files Browse the repository at this point in the history
- cross-compile binary releases
- update installation instructions in README
  • Loading branch information
Dylan Clendenin committed Nov 23, 2016
1 parent 12dc678 commit dc3ffef
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ _testmain.go

mongodb_exporter
vendor/
release/
9 changes: 9 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
package = github.com/dcu/mongodb_exporter
TAG := $(shell git tag | sort -r | head -n 1)

test:
go test github.com/dcu/mongodb_exporter/collector -cover -coverprofile=collector_coverage.out -short
go tool cover -func=collector_coverage.out
Expand All @@ -11,3 +14,9 @@ deps:
build: deps
go build mongodb_exporter.go

release: deps
mkdir -p release
perl -p -i -e 's/{{VERSION}}/$(TAG)/g' mongodb_exporter.go
GOOS=darwin GOARCH=amd64 go build -o release/mongodb_exporter-darwin-amd64 $(package)
GOOS=linux GOARCH=amd64 go build -o release/mongodb_exporter-linux-amd64 $(package)
perl -p -i -e 's/$(TAG)/{{VERSION}}/g' mongodb_exporter.go
9 changes: 2 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,13 @@ MongoDB exporter for prometheus.io, written in go.

## Installing

Requires Go 1.5+

Make sure $GOPATH/bin is in your $PATH, then:

go get -u github.com/dcu/mongodb_exporter
mongodb_exporter -h
Download a [release](https://github.com/dcu/mongodb_exporter/releases)

## Building

Requires [glide](https://github.com/Masterminds/glide) for dependency management

go get -u github.com/dcu/mongodb_exporter
git clone [email protected]:dcu/mongodb_exporter.git $GOPATH/src/github.com/dcu/mongodb_exporter
cd $GOPATH/src/github.com/dcu/mongodb_exporter
make build
./mongodb_exporter -h
Expand Down
5 changes: 5 additions & 0 deletions mongodb_exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ var (
mongodbCollectOplog = flag.Bool("mongodb.collect.oplog", true, "collect Mongodb Oplog status")
mongodbCollectReplSet = flag.Bool("mongodb.collect.replset", true, "collect Mongodb replica set status")
mongodbCollectDatabaseMetrics = flag.Bool("mongodb.collect.database", false, "collect MongoDB database metrics")
version = flag.Bool("version", false, "Print mongodb_exporter version")
)

type basicAuthHandler struct {
Expand Down Expand Up @@ -166,6 +167,10 @@ func createHTTPServerLogWrapper() *slog.Logger {

func main() {
flag.Parse()
if *version {
fmt.Println("mongodb_exporter version: {{VERSION}}")
return
}
shared.ParseEnabledGroups(*enabledGroupsFlag)

startWebServer()
Expand Down

0 comments on commit dc3ffef

Please sign in to comment.