-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
61 lines (54 loc) · 1.61 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
50
51
52
53
54
55
56
57
58
59
60
61
# spin-libsonnet
OUTPUT_DIR := manifests
.PHONY: all
all: help
.PHONY: clean
clean: ## Removes any manifests from previous builds
@for dir in $(shell find * -type d -path '*/$(OUTPUT_DIR)'); do \
echo "Deleting old output directory $${dir}"; \
rm -rf "$${dir}"; \
done
.PHONY: dep
dep: ## Install dependencies
go install github.com/google/go-jsonnet/cmd/jsonnet@latest
go install github.com/google/go-jsonnet/cmd/jsonnetfmt@latest
go install github.com/google/go-jsonnet/cmd/jsonnet-lint@latest
go install github.com/spinnaker/spin@latest
.PHONY: build
build: ## Generate JSON manifests for `spin save`
@jsonnet --version
@export failed=0; \
for dir in $(shell find * -type d | \
grep -v '\(tests\|$(OUTPUT_DIR)\)'); do \
echo "Building $${dir}"; \
cd "$${dir}"; \
for f in $$(find * -name '*.jsonnet'); do \
jsonnet \
--create-output-dirs \
--output-file "$(OUTPUT_DIR)/$${f%%.jsonnet}.json" \
"$${f}" \
|| export failed=1; \
done; \
cd ..; \
done; \
if [ "$$failed" -eq 1 ]; then \
exit 1; \
fi
.PHONY: test
test: ## Test for rendering, formatting and linting errors
@jsonnet --version
@export failed=0; \
for f in $$(find * -name '*.jsonnet' -o -name '*.libsonnet'); do \
echo "Testing $${f}"; \
jsonnet "$${f}" > /dev/null || export failed=1; \
jsonnetfmt --test "$${f}" || export failed=1; \
jsonnet-lint "$${f}" || export failed=1; \
done; \
if [ "$$failed" -eq 1 ]; then \
exit 1; \
fi
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | \
sort | \
awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'