-
Notifications
You must be signed in to change notification settings - Fork 1
/
make-env.Makefile
233 lines (187 loc) · 7.34 KB
/
make-env.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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
DOCKER_ARCH ?= x86_64
GO_ARCH ?= $(shell go env GOARCH)
GO_OS ?= $(shell go env GOOS)
MAKE_ENV_BASE64 ?= $(shell command -v base64)
$(MAKE_ENV_BASE64):
ifeq ($(MAKE_ENV_BASE64),)
echo "MAKE_ENV_BASE64 does not exist/is not on the path"
exit 1
else
stat $(MAKE_ENV_BASE64) >/dev/null
endif
MAKE_ENV_CHMOD ?= $(shell command -v chmod)
$(MAKE_ENV_CHMOD):
ifeq ($(MAKE_ENV_CHMOD),)
echo "MAKE_ENV_CHMOD does not exist/is not on the path"
exit 1
else
stat $(MAKE_ENV_CHMOD) >/dev/null
endif
MAKE_ENV_CURL ?= $(shell command -v curl)
$(MAKE_ENV_CURL):
ifeq ($(MAKE_ENV_CURL),)
echo "MAKE_ENV_CURL does not exist/is not on the path"
exit 1
else
stat $(MAKE_ENV_CURL) >/dev/null
endif
MAKE_ENV_GO ?= $(shell command -v go)
$(MAKE_ENV_GO):
ifeq ($(MAKE_ENV_GO),)
echo "MAKE_ENV_GO does not exist/is not on the path"
exit 1
else
stat $(MAKE_ENV_GO) >/dev/null
endif
MAKE_ENV_LN ?= $(shell command -v ln)
$(MAKE_ENV_LN):
ifeq ($(MAKE_ENV_LN),)
echo "MAKE_ENV_LN does not exist/is not on the path"
exit 1
else
stat $(MAKE_ENV_LN) >/dev/null
endif
MAKE_ENV_MKDIR ?= $(shell command -v mkdir)
$(MAKE_ENV_MKDIR):
ifeq ($(MAKE_ENV_MKDIR),)
echo "MAKE_ENV_MKDIR does not exist/is not on the path"
exit 1
else
stat $(MAKE_ENV_MKDIR) >/dev/null
endif
MAKE_ENV_RM ?= $(shell command -v rm)
$(MAKE_ENV_RM):
ifeq ($(MAKE_ENV_RM),)
echo "MAKE_ENV_RM does not exist/is not on the path"
exit 1
else
stat $(MAKE_ENV_RM) >/dev/null
endif
MAKE_ENV_TAR ?= $(shell command -v tar)
$(MAKE_ENV_TAR):
ifeq ($(MAKE_ENV_TAR),)
echo "MAKE_ENV_TAR does not exist/is not on the path"
exit 1
else
stat $(MAKE_ENV_TAR) >/dev/null
endif
MAKE_ENV_TOUCH ?= $(shell command -v touch)
$(MAKE_ENV_TOUCH):
ifeq ($(MAKE_ENV_TOUCH),)
echo "MAKE_ENV_TOUCH does not exist/is not on the path"
exit 1
else
stat $(MAKE_ENV_TOUCH) >/dev/null
endif
MAKE_ENV_UNZIP ?= $(shell command -v unzip)
$(MAKE_ENV_UNZIP):
ifeq ($(MAKE_ENV_UNZIP),)
echo "MAKE_ENV_UNZIP does not exist/is not on the path"
exit 1
else
stat $(MAKE_ENV_UNZIP) >/dev/null
endif
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
$(MAKE_ENV_MKDIR) -p $(LOCALBIN)
$(MAKE_ENV_TOUCH) $(LOCALBIN)
$(LOCALBIN)/: $(LOCALBIN)
DOCKER ?= $(LOCALBIN)/docker
DOCKER_MIRROR ?= https://download.docker.com/linux/static/stable
DOCKER_VERSION ?= 27.1.0
DOCKER_URL ?= $(DOCKER_MIRROR)/$(DOCKER_ARCH)/docker-$(DOCKER_VERSION).tgz
$(DOCKER):
$(MAKE_ENV_MKDIR) -p $(LOCALBIN)/.make-env/http/$(shell echo $(DOCKER_URL) | base64 -w0)
$(MAKE_ENV_CURL) -vfL $(DOCKER_URL) | tar -x -z -C $(LOCALBIN)/.make-env/http/$(shell echo $(DOCKER_URL) | base64 -w0) docker/docker
$(MAKE_ENV_CHMOD) +x $(LOCALBIN)/.make-env/http/$(shell echo $(DOCKER_URL) | base64 -w0)/docker/docker
$(MAKE_ENV_RM) -f $(DOCKER)
$(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/http/$(shell echo $(DOCKER_URL) | base64 -w0)/docker/docker $(DOCKER)
.PHONY: docker
docker: $(DOCKER)
DOCKER_BUILDX ?= $(LOCALBIN)/docker-buildx
DOCKER_BUILDX_MIRROR ?= https://github.com/docker/buildx/releases/download
DOCKER_BUILDX_VERSION ?= v0.16.1
DOCKER_BUILDX_URL ?= $(DOCKER_BUILDX_MIRROR)/$(DOCKER_BUILDX_VERSION)/buildx-$(DOCKER_BUILDX_VERSION).$(GO_OS)-$(GO_ARCH)
$(DOCKER_BUILDX):
$(MAKE_ENV_MKDIR) -p $(LOCALBIN)/.make-env/http
$(MAKE_ENV_CURL) -vfL $(DOCKER_BUILDX_URL) -o $(LOCALBIN)/.make-env/http$(shell echo $(DOCKER_BUILDX_URL) | base64 -w0)
$(MAKE_ENV_CHMOD) +x $(LOCALBIN)/.make-env/http$(shell echo $(DOCKER_BUILDX_URL) | base64 -w0)
$(MAKE_ENV_RM) -f $(DOCKER_BUILDX)
$(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/http$(shell echo $(DOCKER_BUILDX_URL) | base64 -w0) $(DOCKER_BUILDX)
.PHONY: docker-buildx
docker-buildx: $(DOCKER_BUILDX)
GINKGO ?= $(LOCALBIN)/ginkgo
GINKGO_VERSION ?= $(shell go mod edit -print | grep ginkgo | cut -d ' ' -f2)
$(GINKGO): $(MAKE_ENV_GO)
GOBIN=$(LOCALBIN)/.make-env/go/github.com/onsi/ginkgo/v2/ginkgo/$(GINKGO_VERSION) \
$(MAKE_ENV_GO) install \
github.com/onsi/ginkgo/v2/ginkgo@$(GINKGO_VERSION)
$(MAKE_ENV_RM) -f $(GINKGO)
$(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/go/github.com/onsi/ginkgo/v2/ginkgo/$(GINKGO_VERSION)/ginkgo $(GINKGO)
.PHONY: ginkgo
ginkgo: $(GINKGO)
HELM ?= $(LOCALBIN)/helm
HELM_MIRROR ?= https://dl.k8s.io/release
HELM_VERSION ?= v3.12.2
HELM_URL ?= https://get.helm.sh/helm-$(HELM_VERSION)-$(GO_OS)-$(GO_ARCH).tar.gz
$(HELM):
$(MAKE_ENV_MKDIR) -p $(LOCALBIN)/.make-env/http/$(shell echo $(HELM_URL) | base64 -w0)
$(MAKE_ENV_CURL) -vfL $(HELM_URL) | tar -x -z -C $(LOCALBIN)/.make-env/http/$(shell echo $(HELM_URL) | base64 -w0) $(GO_OS)-$(GO_ARCH)/helm
$(MAKE_ENV_CHMOD) +x $(LOCALBIN)/.make-env/http/$(shell echo $(HELM_URL) | base64 -w0)/$(GO_OS)-$(GO_ARCH)/helm
$(MAKE_ENV_RM) -f $(HELM)
$(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/http/$(shell echo $(HELM_URL) | base64 -w0)/$(GO_OS)-$(GO_ARCH)/helm $(HELM)
.PHONY: helm
helm: $(HELM)
HELM_HOG ?= $(LOCALBIN)/helm-hog
$(HELM_HOG): $(MAKE_ENV_GO)
GOBIN=$(LOCALBIN)/.make-env/go/github.com/meln5674/helm-hog/3af9ec621dcc359e38e966a255571a39beefe624 \
$(MAKE_ENV_GO) install \
github.com/meln5674/helm-hog@3af9ec621dcc359e38e966a255571a39beefe624
$(MAKE_ENV_RM) -f $(HELM_HOG)
$(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/go/github.com/meln5674/helm-hog/3af9ec621dcc359e38e966a255571a39beefe624/helm-hog $(HELM_HOG)
.PHONY: helm-hog
helm-hog: $(HELM_HOG)
KIND ?= $(LOCALBIN)/kind
KIND_MIRROR ?= https://github.com/kubernetes-sigs/kind/releases/download
KIND_VERSION ?= v0.17.0
KIND_URL ?= $(KIND_MIRROR)/$(KIND_VERSION)/kind-$(GO_OS)-$(GO_ARCH)
$(KIND):
$(MAKE_ENV_MKDIR) -p $(LOCALBIN)/.make-env/http
$(MAKE_ENV_CURL) -vfL $(KIND_URL) -o $(LOCALBIN)/.make-env/http$(shell echo $(KIND_URL) | base64 -w0)
$(MAKE_ENV_CHMOD) +x $(LOCALBIN)/.make-env/http$(shell echo $(KIND_URL) | base64 -w0)
$(MAKE_ENV_RM) -f $(KIND)
$(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/http$(shell echo $(KIND_URL) | base64 -w0) $(KIND)
.PHONY: kind
kind: $(KIND)
KUBECTL ?= $(LOCALBIN)/kubectl
KUBECTL_MIRROR ?= https://dl.k8s.io/release
KUBECTL_VERSION ?= v1.25.11
KUBECTL_URL ?= $(KUBECTL_MIRROR)/$(KUBECTL_VERSION)/bin/$(GO_OS)/$(GO_ARCH)/kubectl
$(KUBECTL):
$(MAKE_ENV_MKDIR) -p $(LOCALBIN)/.make-env/http
$(MAKE_ENV_CURL) -vfL $(KUBECTL_URL) -o $(LOCALBIN)/.make-env/http$(shell echo $(KUBECTL_URL) | base64 -w0)
$(MAKE_ENV_CHMOD) +x $(LOCALBIN)/.make-env/http$(shell echo $(KUBECTL_URL) | base64 -w0)
$(MAKE_ENV_RM) -f $(KUBECTL)
$(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/http$(shell echo $(KUBECTL_URL) | base64 -w0) $(KUBECTL)
.PHONY: kubectl
kubectl: $(KUBECTL)
YQ ?= $(LOCALBIN)/yq
YQ_MIRROR ?= github.com/mikefarah/yq/releases/download
YQ_VERSION ?= v4.44.1
YQ_URL ?= https://$(YQ_MIRROR)/$(YQ_VERSION)/yq_$(GO_OS)_$(GO_ARCH).tar.gz
$(YQ):
$(MAKE_ENV_MKDIR) -p $(LOCALBIN)/.make-env/http/$(shell echo $(YQ_URL) | base64 -w0)
$(MAKE_ENV_CURL) -vfL $(YQ_URL) | tar -x -z -C $(LOCALBIN)/.make-env/http/$(shell echo $(YQ_URL) | base64 -w0) ./yq_$(GO_OS)_$(GO_ARCH)
$(MAKE_ENV_CHMOD) +x $(LOCALBIN)/.make-env/http/$(shell echo $(YQ_URL) | base64 -w0)/./yq_$(GO_OS)_$(GO_ARCH)
$(MAKE_ENV_RM) -f $(YQ)
$(MAKE_ENV_LN) -s $(LOCALBIN)/.make-env/http/$(shell echo $(YQ_URL) | base64 -w0)/./yq_$(GO_OS)_$(GO_ARCH) $(YQ)
.PHONY: yq
yq: $(YQ)
.PHONY: all-e2e-tools
all-e2e-tools: $(GINKGO) $(KUBECTL) $(HELM) $(DOCKER) $(KIND) $(HELM_HOG)
.PHONY: all-helm-tools
all-helm-tools: $(YQ) $(HELM) $(HELM_HOG) $(DOCKER) $(KIND)
.PHONY: all-test-tools
all-test-tools: $(GINKGO)
make-env.Makefile: make-env.yaml
make-env --config 'make-env.yaml' --out 'make-env.Makefile'