-
Notifications
You must be signed in to change notification settings - Fork 332
/
Makefile
150 lines (130 loc) · 4.48 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
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
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
HELM_IMAGE = alpine/helm:3.16.2
HELM_DOCS_IMAGE = local/helm-docs:v1.14.144
CT_IMAGE = quay.io/helmpack/chart-testing:v3.11.0
HELM?=helm-docker
CT?=ct-docker
CONTAINER_TOOL ?= docker
REPODIR := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
WORKDIR := $(REPODIR)/..
include $(shell find hack -name Makefile)
ifeq ($(CONTAINER_TOOL),docker)
CONTAINER_USER_OPTION = --user $(shell id -u):$(shell id -g)
CONTAINER_VOLUME_OPTION_SUFFIX =
else
ifeq ($(CONTAINER_TOOL),podman)
CONTAINER_USER_OPTION =
CONTAINER_VOLUME_OPTION_SUFFIX = :z
else
$(error CONTAINER values currently supported are: docker, podman)
endif
endif
helm-docker:
mkdir -p .helm/cache
$(CONTAINER_TOOL) run --rm --name helm-exec \
$(CONTAINER_USER_OPTION) \
--volume "$(PWD):/helm-charts$(CONTAINER_VOLUME_OPTION_SUFFIX)" \
--volume "$(PWD)/.github/ci/helm-repos.yaml:/helm-charts/.helm/config/repositories.yaml$(CONTAINER_VOLUME_OPTION_SUFFIX)" \
-w /helm-charts \
-e HELM_CACHE_HOME=/helm-charts/.helm/cache \
-e HELM_CONFIG_HOME=/helm-charts/.helm/config \
-e HELM_DATA_HOME=/helm-charts/.helm/data \
$(HELM_IMAGE) \
$(CMD)
helm-local:
helm \
$(CMD)
ct-docker:
mkdir -p .helm/cache
$(CONTAINER_TOOL) run --rm --name helm-exec \
$(CONTAINER_USER_OPTION) \
--volume "$(PWD):/helm-charts$(CONTAINER_VOLUME_OPTION_SUFFIX)" \
--volume "$(PWD)/.github/ci/helm-repos.yaml:/helm-charts/.helm/config/repositories.yaml$(CONTAINER_VOLUME_OPTION_SUFFIX)" \
-w /helm-charts \
-e HELM_CACHE_HOME=/helm-charts/.helm/cache \
-e HELM_CONFIG_HOME=/helm-charts/.helm/config \
-e HELM_DATA_HOME=/helm-charts/.helm/data \
--entrypoint 'ct' \
$(CT_IMAGE) \
$(CMD)
ct-local:
ct \
$(CMD)
helm-plugins:
CMD="plugin install https://github.com/helm-unittest/helm-unittest.git" $(MAKE) $(HELM)
helm-repo-update:
CMD="repo update" $(MAKE) $(HELM)
# Run linter for helm chart
lint: helm-repo-update
$(foreach values,$(wildcard hack/helm/*/lint/*.yaml), \
$(eval chart := $(word 3, $(subst /, ,$(values)))) \
CMD="dep build charts/$(chart)" $(MAKE) $(HELM) || exit 1; \
CMD="lint charts/$(chart) -f $(values)" $(MAKE) $(HELM) || exit 1; \
)
update: helm-repo-update
$(foreach values,$(wildcard hack/helm/*/lint/*.yaml), \
$(eval chart := $(word 3, $(subst /, ,$(values)))) \
CMD="dep update charts/$(chart)" $(MAKE) $(HELM) || exit 1; \
)
# Run template for helm charts
template: helm-repo-update
$(foreach values,$(wildcard hack/helm/*/lint/*.yaml), \
$(eval chart := $(word 3, $(subst /, ,$(values)))) \
CMD="dep build charts/$(chart)" $(MAKE) $(HELM) || exit 1; \
CMD="template charts/$(chart) -f $(values)" $(MAKE) $(HELM) || exit 1; \
)
unittest: helm-repo-update
$(foreach values,$(wildcard */*/tests), \
$(eval chart := $(word 2, $(subst /, ,$(values)))) \
$(eval location := $(word 1, $(subst /, ,$(values)))) \
CMD="dep build $(location)/$(chart)" $(MAKE) $(HELM) || exit 1; \
CMD="unittest $(location)/$(chart)" $(MAKE) $(HELM) || exit 1; \
)
lint-ct:
CMD="lint --config .github/ci/ct.yaml --all" $(MAKE) $(CT)
lint-ct-local:
CT="ct-local" $(MAKE) lint-ct
lint-local:
HELM="helm-local" $(MAKE) lint
template-local:
HELM="helm-local" $(MAKE) template
gen-docs:
$(CONTAINER_TOOL) build $(PWD)/hack/docs \
-t $(HELM_DOCS_IMAGE) && \
$(CONTAINER_TOOL) run --rm \
$(CONTAINER_USER_OPTION) \
--volume "$(PWD):/helm-charts$(CONTAINER_VOLUME_OPTION_SUFFIX)" \
-w /helm-charts \
--entrypoint /bin/helm-docs \
$(HELM_DOCS_IMAGE) \
-c charts \
-t hack/docs/template.tmpl -t README.md.gotmpl
docs-image:
if [ ! -d $(WORKDIR)/vmdocs ]; then \
git clone --depth 1 [email protected]:VictoriaMetrics/vmdocs $(WORKDIR)/vmdocs; \
fi; \
cd $(WORKDIR)/vmdocs && \
git checkout main && \
git pull origin main && \
cd $(REPODIR) && \
$(CONTAINER_TOOL) build \
-t vmdocs \
$(WORKDIR)/vmdocs
docs-debug: gen-docs docs-image
$(CONTAINER_TOOL) run \
--rm \
--name vmdocs \
-p 1313:1313 \
-v ./:/opt/docs/content/helm \
$(foreach chart,$(wildcard charts/*), -v ./$(chart):/opt/docs/content/helm/$(basename $(chart))) \
vmdocs
docs-images-to-webp: docs-image
$(CONTAINER_TOOL) run \
--rm \
--entrypoint /usr/bin/find \
--name vmdocs \
-v ./:/opt/docs/content/helm \
$(foreach chart,$(wildcard charts/*), -v ./$(chart):/opt/docs/content/helm/$(basename $(chart))) \
vmdocs \
content/helm \
-regex ".*\.\(png\|jpg\|jpeg\)" \
-exec sh -c 'cwebp -preset drawing -m 6 -o $$(echo {} | cut -f-1 -d.).webp {} && rm -rf {}' {} \;