-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
49 lines (37 loc) · 1.67 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# A Self-Documenting Makefile: http://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
IMAGE_NAME := emq_exporter
IMAGE_TAG ?= $(subst /,-,$(shell git rev-parse --abbrev-ref HEAD))
IP = $(shell docker inspect -f '{{range .NetworkSettings.Networks}}{{.IPAddress}}{{end}}' emqx)
GO111MODULE := on
GO ?= GO111MODULE=$(GO111MODULE) go
all: test build ## Run tests and build the binary
init:
@echo ">> running go mod download"
$(GO) get -v github.com/onsi/ginkgo/ginkgo
$(GO) get -v github.com/onsi/gomega
$(GO) get -v -t ./...
$(GO) mod download
fmt: ## Format code using go fmt
@echo ">> formatting code"
$(GO) fmt ./...
vet: ## Vet code using go vet
@echo ">> vetting code"
$(GO) vet ./...
build: fmt vet test ## Build binaries
@echo ">> building binaries"
$(GO) build -o ./bin/emq_exporter .
test: fmt vet ## Run tests using go test
@echo ">> running tests"
ginkgo -r --randomizeAllSpecs --randomizeSuites --failOnPending --cover --trace --race --compilers=2
docker: build ## Build docker image
@echo ">> building docker image"
@docker build -t "${IMAGE_NAME}:${IMAGE_TAG}" .
local: ## Start a local emq container for development
@echo ">> starting emqx container"
@docker kill emqx || true
@docker run --rm -d --name emqx -h emqx -p 18083:18083 -p 8080:8080 emqx/emqx:latest
run: build local ## Run the exporter locally using a local container
./bin/emq_exporter --emq.node emqx@$(IP) --emq.creds-file testdata/authfull.json --emq.api-version v4 --debug
help: ## Print this message and exit
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%-20s %s\n", $$1, $$2}'
.PHONY: all fmt vet build docker bootstrap local run help