forked from Kong/charts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
50 lines (39 loc) · 1.35 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
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
.PHONY: _download_tool
_download_tool:
(cd third_party && go mod tidy && \
GOBIN=$(PROJECT_DIR)/bin go generate -tags=third_party ./$(TOOL).go )
.PHONY: tools
tools: kube-linter chartsnap
KUBE_LINTER = $(PROJECT_DIR)/bin/kube-linter
.PHONY: kube-linter
kube-linter:
@$(MAKE) _download_tool TOOL=kube-linter
.PHONY: chartsnap
chartsnap:
@helm plugin list | grep chartsnap > /dev/null || \
helm plugin install https://github.com/jlandowner/helm-chartsnap
.PHONY: lint
lint: tools lint.charts.kong lint.shellcheck
.PHONY: lint.charts.kong
lint.charts.kong:
$(KUBE_LINTER) lint charts/kong
lint.shellcheck:
shellcheck ./scripts/*
GOLDEN_TEST_CHART ?= kong
GOLDEN_TEST_CHART_VALUES_DIR ?= ./charts/kong/ci/
CHARTSNAP_COMMAND = helm chartsnap -c ./charts/$(GOLDEN_TEST_CHART) -f $(GOLDEN_TEST_CHART_VALUES_DIR)
# Defining multi-line strings to echo: https://stackoverflow.com/a/649462/7958339
define GOLDEN_TEST_FAILURE_MSG
>> Golden tests have failed.
>> Please run 'make test.golden.update' to update golden files and commit the changes if they're expected.
endef
export GOLDEN_TEST_FAILURE_MSG
.PHONY: test.golden
test.golden: chartsnap
@ $(CHARTSNAP_COMMAND) || \
(echo "$$GOLDEN_TEST_FAILURE_MSG" && \
exit 1)
.PHONY: test.golden.update
test.golden.update: chartsnap
$(CHARTSNAP_COMMAND) -u