2023-06-21 15:02:11 +00:00
|
|
|
# List make commands
|
|
|
|
.PHONY: ls
|
|
|
|
ls:
|
|
|
|
cat Makefile | grep "^[a-zA-Z#].*" | cut -d ":" -f 1 | sed s';#;\n#;'g
|
2023-06-19 19:06:18 +00:00
|
|
|
|
2023-06-21 15:02:11 +00:00
|
|
|
# Download dependencies
|
|
|
|
.PHONY: download
|
2023-06-19 18:37:27 +00:00
|
|
|
download:
|
2023-06-19 17:58:16 +00:00
|
|
|
go mod download
|
2021-02-05 22:49:47 +00:00
|
|
|
|
2023-06-21 15:02:11 +00:00
|
|
|
# Update project dependencies
|
|
|
|
.PHONY: update
|
|
|
|
update:
|
|
|
|
go get -u
|
|
|
|
go mod download
|
|
|
|
go mod tidy
|
|
|
|
|
|
|
|
# Run project tests
|
|
|
|
.PHONY: test
|
2023-06-19 18:37:27 +00:00
|
|
|
test: download
|
2023-06-19 17:58:16 +00:00
|
|
|
go test ./... -v -race
|
2021-10-17 17:39:02 +00:00
|
|
|
|
2023-06-21 15:02:11 +00:00
|
|
|
# Format code
|
|
|
|
.PHONY: fmt
|
2023-06-19 18:37:27 +00:00
|
|
|
fmt: download
|
2023-06-21 15:02:11 +00:00
|
|
|
go mod tidy
|
2023-06-19 17:58:16 +00:00
|
|
|
go fmt ./...
|
2021-10-17 17:39:02 +00:00
|
|
|
|
2023-06-21 15:02:11 +00:00
|
|
|
# Check for unformatted go code
|
|
|
|
.PHONY: check/fmt
|
2023-06-19 18:37:27 +00:00
|
|
|
check/fmt: download
|
|
|
|
test -z $(shell gofmt -l .)
|
2022-02-12 17:31:01 +00:00
|
|
|
|
2023-06-21 15:02:11 +00:00
|
|
|
# Build project
|
|
|
|
.PHONY: build
|
2023-06-19 18:37:27 +00:00
|
|
|
build:
|
2023-06-22 15:22:42 +00:00
|
|
|
CGO_ENABLED=0 go build \
|
2023-06-19 18:37:27 +00:00
|
|
|
-ldflags "\
|
|
|
|
-X main.version=${shell git describe --tags} \
|
|
|
|
-X main.commit=${shell git rev-parse HEAD} \
|
|
|
|
-X main.date=${shell date --iso-8601=seconds} \
|
|
|
|
-X main.builtBy=manual \
|
|
|
|
" \
|
|
|
|
-o fail2ban_exporter \
|
|
|
|
exporter.go
|
2023-06-19 19:06:18 +00:00
|
|
|
|
2023-06-21 15:02:11 +00:00
|
|
|
# Build project docker container
|
|
|
|
.PHONY: build/docker
|
2023-06-19 19:06:18 +00:00
|
|
|
build/docker: build
|
|
|
|
docker build -t fail2ban-prometheus-exporter .
|