Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
111 lines (92 loc) · 4.1 KB
/
Copy pathMakefile
File metadata and controls
111 lines (92 loc) · 4.1 KB
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
VERSION := $(shell git describe --tags --always --dirty 2>/dev/null || echo dev)
COMMIT := $(shell git rev-parse --short HEAD 2>/dev/null || echo unknown)
BUILD_DATE := $(shell date -u +%Y-%m-%dT%H:%M:%SZ)
LDFLAGS := -s -w \
-X github.com/Obmondo/kubeaid-cli/cmd/kubeaid-core/root/version.Version=$(VERSION) \
-X github.com/Obmondo/kubeaid-cli/cmd/kubeaid-core/root/version.Commit=$(COMMIT) \
-X github.com/Obmondo/kubeaid-cli/cmd/kubeaid-core/root/version.Date=$(BUILD_DATE)
MANAGEMENT_CLUSTER_NAME := kubeaid-bootstrapper
default: help ## Run help by default
help: ## This help screen
@printf "Available targets:\n\n"
@awk 'BEGIN { FS = ":.*## " } /^[a-zA-Z0-9][a-zA-Z0-9_-]*:/ { \
target = $$1; \
sub(/:.*/, "", target); \
rest = substr($$0, index($$0, ":") + 1); \
while (substr(rest, 1, 1) == " " || substr(rest, 1, 1) == "\t") { \
rest = substr(rest, 2); \
} \
if (substr(rest, 1, 1) == "=") { \
next; \
} \
description = "No description"; \
if (index($$0, "## ") > 0) { \
description = $$2; \
} \
printf " \x1b[32;01m%-35s\x1b[0m %s\n", target, description; \
}' $(MAKEFILE_LIST) | sort -u
@printf "\n"
.PHONY: format
format: ## Run formatter checks
@golangci-lint fmt
.PHONY: lint
lint: ## Run Go linters
@golangci-lint run ./...
.PHONY: addlicense
addlicense: ## Add Apache-2.0 headers to Go files
@find . -name '*.go' -exec addlicense -c "Obmondo" -l "apache" -s {} +
.PHONY: test
test: ## Run unit tests and write coverage.out
@go test -count=1 -covermode=atomic -coverprofile=coverage.out ./...
.PHONY: coverage
coverage: test ## Open the per-file HTML coverage report in a browser
@go tool cover -html=coverage.out
# Same pin as the "Check test coverage" step in .github/workflows/ci.yaml.
.PHONY: check-coverage
check-coverage: test ## Enforce testcoverage.yaml thresholds
@go run github.com/vladopajic/go-test-coverage/v2@v2.19.0 --config=./testcoverage.yaml
.PHONY: run-generators
run-generators: ## Generate config artifacts
@go run ./tools/generators/cmd \
./pkg/config/general.go ./pkg/config/secrets.go
.PHONY: fetch-k8s-eol
fetch-k8s-eol: ## Refresh embedded K8s EOL data from endoflife.date
@./tools/generators/cmd/fetch-k8s-eol.sh
.PHONY: check-k8s-eol
check-k8s-eol: ## Check that pkg/config/parser/k8s-eol.json is up to date with endoflife.date
@./tools/generators/cmd/fetch-k8s-eol.sh
@if ! git diff --quiet -- pkg/config/parser/k8s-eol.json; then \
echo ""; \
echo "pkg/config/parser/k8s-eol.json is out of date relative to endoflife.date."; \
echo "Run 'make fetch-k8s-eol' locally and commit the refreshed file."; \
echo ""; \
git --no-pager diff -- pkg/config/parser/k8s-eol.json; \
exit 1; \
fi
@echo "pkg/config/parser/k8s-eol.json is up to date with endoflife.date"
.PHONY: check-generated
check-generated: ## Check that generated config artifacts are up to date with the config structs
@go run ./tools/generators/cmd \
./pkg/config/general.go ./pkg/config/secrets.go
@if ! git diff --quiet -- docs/config-reference.md cmd/kubeaid-core/root/config/templates; then \
echo ""; \
echo "Generated config artifacts are out of date relative to pkg/config."; \
echo "Run 'make run-generators' locally and commit the regenerated files."; \
echo ""; \
git --no-pager diff --stat -- docs/config-reference.md cmd/kubeaid-core/root/config/templates; \
exit 1; \
fi
@echo "Generated config artifacts are up to date with pkg/config"
.PHONY: build
build: ## Build kubeaid-cli binary
@CGO_ENABLED=0 go build -ldflags="$(LDFLAGS)" -o ./build/kubeaid-cli ./cmd/kubeaid-cli
.PHONY: build-storagectl
build-storagectl: ## Build kubeaid-storagectl binary
@go build -ldflags="$(LDFLAGS)" -o ./build/kubeaid-storagectl ./cmd/kubeaid-storagectl
# CONFIGS_DIR matches the contributor flow in docs/DEVELOPMENT.md; outputs
# land in the configs directory the run was pointed at.
CONFIGS_DIR ?= ./outputs/configs/local
.PHONY: management-cluster-delete
management-cluster-delete: ## Delete the management k3d cluster (set CONFIGS_DIR=<path> if not the DEVELOPMENT.md default)
KUBECONFIG="$(CONFIGS_DIR)/kubeconfigs/management/container.yaml" \
k3d cluster delete $(MANAGEMENT_CLUSTER_NAME)