Skip to content

Commit a7d406e

Browse files
authored
Merge pull request #358 from mbaldessari/fix-ci-bits
Stop pulling scripts from github.com
2 parents caa2200 + 27ee2f2 commit a7d406e

File tree

1 file changed

+27
-22
lines changed

1 file changed

+27
-22
lines changed

Makefile

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -188,16 +188,23 @@ LOCALBIN ?= $(shell pwd)/bin
188188
$(LOCALBIN):
189189
mkdir -p $(LOCALBIN)
190190

191-
KUSTOMIZE ?= $(LOCALBIN)/kustomize
192-
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
193-
ENVTEST ?= $(LOCALBIN)/setup-envtest
194-
195191
## Tool Versions
196-
KUSTOMIZE_VERSION ?= v5.4.3
192+
KUSTOMIZE_VERSION ?= v5.3.0
197193
CONTROLLER_TOOLS_VERSION ?= v0.16.4
198-
OPERATOR_SDK_VERSION ?= v1.37.0
194+
ENVTEST_VERSION ?= release-0.19
195+
GOLANGCI_LINT_VERSION ?= v2.0.2
196+
# update for major version updates to YQ_VERSION!
197+
YQ_API_VERSION = v4
198+
YQ_VERSION = v4.41.1
199+
KUSTOMIZE_VERSION ?= v5.4.3
200+
KUSTOMIZE ?= $(LOCALBIN)/kustomize-$(KUSTOMIZE_VERSION)
201+
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen-$(CONTROLLER_TOOLS_VERSION)
202+
ENVTEST ?= $(LOCALBIN)/setup-envtest-$(ENVTEST_VERSION)
203+
GOLANGCI_LINT = $(LOCALBIN)/golangci-lint-$(GOLANGCI_LINT_VERSION)
204+
YQ = $(LOCALBIN)/yq-$(YQ_VERSION)
199205

200-
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
206+
## Tool Versions
207+
OPERATOR_SDK_VERSION ?= v1.37.0
201208

202209
.PHONY: operator-sdk
203210
OPERATOR_SDK ?= $(LOCALBIN)/operator-sdk
@@ -214,32 +221,30 @@ endif
214221

215222
.PHONY: controller-gen
216223
controller-gen: ## Download controller-gen locally if necessary.
217-
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION))
224+
$(call go-install-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen,$(CONTROLLER_TOOLS_VERSION))
218225

219226
.PHONY: kustomize
220227
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary. If wrong version is installed, it will be removed before downloading.
221228
$(KUSTOMIZE): $(LOCALBIN)
222-
@if test -x $(LOCALBIN)/kustomize && ! $(LOCALBIN)/kustomize version | grep -q $(KUSTOMIZE_VERSION); then \
223-
echo "$(LOCALBIN)/kustomize version is not expected $(KUSTOMIZE_VERSION). Removing it before installing."; \
224-
rm -rf $(LOCALBIN)/kustomize; \
225-
fi
226-
test -s $(LOCALBIN)/kustomize || { curl -Ss $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }
229+
$(call go-install-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v5,$(KUSTOMIZE_VERSION))
227230

228231
.PHONY: envtest
229232
envtest: ## Download envtest-setup locally if necessary.
230-
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@release-0.19)
233+
$(call go-install-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest,$(ENVTEST_VERSION))
231234

232235
# go-get-tool will 'go get' any package $2 and install it to $1.
233236
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
234-
define go-get-tool
237+
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
238+
# $1 - target path with name of binary (ideally with version)
239+
# $2 - package url which can be installed
240+
# $3 - specific version of package
241+
define go-install-tool
235242
@[ -f $(1) ] || { \
236-
set -e ;\
237-
TMP_DIR=$$(mktemp -d) ;\
238-
cd $$TMP_DIR ;\
239-
go mod init tmp ;\
240-
echo "Downloading $(2)" ;\
241-
export GOFLAGS=""; GOBIN=$(PROJECT_DIR)/bin go install $(2) ;\
242-
rm -rf $$TMP_DIR ;\
243+
set -e; \
244+
package=$(2)@$(3) ;\
245+
echo "Downloading $${package}" ;\
246+
GOBIN=$(LOCALBIN) go install $${package} ;\
247+
mv "$$(echo "$(1)" | sed "s/-$(3)$$//")" $(1) ;\
243248
}
244249
endef
245250

0 commit comments

Comments
 (0)