Skip to content

Commit

Permalink
Implement 'make help' command
Browse files Browse the repository at this point in the history
  • Loading branch information
satk0 committed Jul 4, 2023
1 parent 46221ca commit 26f03a2
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ VERSION ?= $(shell git symbolic-ref --short HEAD)
GIT_COMMIT := $(shell git rev-parse HEAD)
DOCKER_IMG ?= "logstash-exporter"

# ****************************** NOTE ****************************** #
# Commands description was made using the following syntax: #
# https://stackoverflow.com/a/59087509 #
# #
# To write command description use "#:" before command definition #
# ****************************************************************** #

#: Builds binary executables for all OS (Win, Darwin, Linux)
all: $(GOOS_BINARIES)

VERSIONINFO_PKG := config
Expand All @@ -18,55 +26,82 @@ ldflags := -s -w \
out/main-%:
CGO_ENABLED=0 GOOS=$* go build -a -installsuffix cgo -ldflags="$(ldflags)" -o out/main-$* cmd/exporter/main.go

#: Runs the Go Exporter application
run:
go run cmd/exporter/main.go

#: Builds a binary executable for Linux
build-linux: out/main-linux
#: Builds a binary executable for Darwin
build-darwin: out/main-darwin
#: Builds a binary executable for Windows
build-windows: out/main-windows

#: Builds a Docker image for the Go Exporter application
build-docker:
docker build -t $(DOCKER_IMG) --build-arg VERSION=$(VERSION) --build-arg GIT_COMMIT=$(GIT_COMMIT) .

# Builds for Linux X86, Apple Silicon/AWS Graviton. Requires docker buildx (Docker 19.03+)
#: Builds a multi-arch Docker image (`amd64` and `arm64`)
build-docker-multi:
docker buildx build --platform linux/amd64,linux/arm64 -t $(DOCKER_IMG) --push .

#: Deletes all binary executables in the out directory
clean:
rm -f $(GOOS_EXES)

#: Runs all tests
test:
go test -race -v ./...

#: Displays test coverage report
test-coverage:
go test -race -coverprofile=coverage.out ./...
go tool cover -html=coverage.out

#: Starts a Docker-compose configuration
compose:
docker-compose up -d --build

#: Starts a Docker-compose configuration until it's ready
wait-for-compose:
docker-compose up -d --wait

#: Stops a Docker-compose configuration
compose-down:
docker-compose down

#: Verifies the metrics from the Go Exporter application
verify-metrics:
./scripts/verify_metrics.sh

#: Pulls the Docker image from the registry
pull:
docker-compose pull

#: Shows logs from the Docker-compose configuration
logs:
docker-compose logs -f

#: Minifies the binary executables.
minify:
upx -9 $(GOOS_EXES)

#: Installs readme-generator-for-helm tool.
install-helm-readme:
./scripts/install_helm_readme_generator.sh

#: Generates Helm chart README.md file.
helm-readme:
./scripts/generate_helm_readme.sh

#: Show this help about available commands
help:
@grep -B1 -E "^[a-zA-Z0-9_-]+\:([^\=]|$$)" Makefile \
| grep -v -- -- \
| sed 'N;s/\n/###/' \
| sed -n 's/^#: \(.*\)###\(.*\):.*/\2###\1/p' \
| column -t -s '###'


.DEFAULT_GOAL := run

0 comments on commit 26f03a2

Please sign in to comment.