2023-06-21 17:02:11 +02:00
|
|
|
# List make commands
|
|
|
|
.PHONY: ls
|
|
|
|
ls:
|
|
|
|
cat Makefile | grep "^[a-zA-Z#].*" | cut -d ":" -f 1 | sed s';#;\n#;'g
|
2023-06-19 21:06:18 +02:00
|
|
|
|
2023-06-21 17:02:11 +02:00
|
|
|
# Download dependencies
|
|
|
|
.PHONY: download
|
2023-06-19 20:37:27 +02:00
|
|
|
download:
|
2023-06-19 19:58:16 +02:00
|
|
|
go mod download
|
2021-02-05 23:49:47 +01:00
|
|
|
|
2023-06-21 17:02:11 +02:00
|
|
|
# Update project dependencies
|
|
|
|
.PHONY: update
|
|
|
|
update:
|
|
|
|
go get -u
|
|
|
|
go mod download
|
|
|
|
go mod tidy
|
|
|
|
|
|
|
|
# Run project tests
|
|
|
|
.PHONY: test
|
2023-06-19 20:37:27 +02:00
|
|
|
test: download
|
2023-06-19 19:58:16 +02:00
|
|
|
go test ./... -v -race
|
2021-10-17 19:39:02 +02:00
|
|
|
|
2023-06-22 20:24:15 +02:00
|
|
|
# Look for "suspicious constructs" in source code
|
|
|
|
.PHONY: vet
|
|
|
|
vet: download
|
|
|
|
go vet ./...
|
|
|
|
|
2023-06-21 17:02:11 +02:00
|
|
|
# Format code
|
|
|
|
.PHONY: fmt
|
2023-06-19 20:37:27 +02:00
|
|
|
fmt: download
|
2023-06-21 17:02:11 +02:00
|
|
|
go mod tidy
|
2023-06-19 19:58:16 +02:00
|
|
|
go fmt ./...
|
2021-10-17 19:39:02 +02:00
|
|
|
|
2023-06-21 17:02:11 +02:00
|
|
|
# Check for unformatted go code
|
|
|
|
.PHONY: check/fmt
|
2023-06-19 20:37:27 +02:00
|
|
|
check/fmt: download
|
|
|
|
test -z $(shell gofmt -l .)
|
2022-02-12 18:31:01 +01:00
|
|
|
|
2023-06-21 17:02:11 +02:00
|
|
|
# Build project
|
|
|
|
.PHONY: build
|
2023-06-19 20:37:27 +02:00
|
|
|
build:
|
2023-06-22 17:22:42 +02:00
|
|
|
CGO_ENABLED=0 go build \
|
2023-06-19 20:37:27 +02: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 21:06:18 +02:00
|
|
|
|
2023-06-21 17:02:11 +02:00
|
|
|
# Build project docker container
|
|
|
|
.PHONY: build/docker
|
2023-10-27 08:01:41 +02:00
|
|
|
build/docker:
|
2023-06-19 21:06:18 +02:00
|
|
|
docker build -t fail2ban-prometheus-exporter .
|