@@ -212,11 +212,38 @@ TMP_DIR=$$(mktemp -d) ;\
212212cd $$TMP_DIR ;\
213213go mod init tmp ;\
214214echo "Downloading $(2 ) " ;\
215- GOBIN=$(PROJECT_DIR ) /bin go get $(2 ) ;\
215+ GOBIN=$(LOCALBIN ) go get $(2 ) ;\
216216rm -rf $$TMP_DIR ;\
217217}
218218endef
219219
220+ # go-install-tool will 'go install' any package $2 and install it to $1.
221+ define go-install-tool
222+ @[ -f $(1 ) ] || { \
223+ set -e ;\
224+ TMP_DIR=$$(mktemp -d ) ;\
225+ cd $$TMP_DIR ;\
226+ go mod init tmp ;\
227+ echo "Downloading $(2 ) " ;\
228+ GOBIN=$(LOCALBIN ) go install $(2 ) ;\
229+ rm -rf $$TMP_DIR ;\
230+ }
231+ endef
232+
233+ # go-install-mod-tool will 'go install' any package $2 and install it to $1.
234+ define go-install-mod-tool
235+ @[ -f $(1 ) ] || { \
236+ set -e ;\
237+ TMP_DIR=$$(mktemp -d ) ;\
238+ cd $$TMP_DIR ;\
239+ go mod init tmp ;\
240+ echo "Downloading $(2 ) " ;\
241+ GOBIN=$(LOCALBIN ) go install -mod=mod $(2 ) ;\
242+ rm -rf $$TMP_DIR ;\
243+ }
244+ endef
245+
246+
220247.PHONY : bundle
221248bundle : manifests kustomize # # Generate bundle manifests and metadata, then validate generated files.
222249 operator-sdk generate kustomize manifests -q
@@ -297,15 +324,15 @@ GINKGO := $(LOCALBIN)/ginkgo
297324GINKGO_URL := github.com/onsi/ginkgo/v2/ginkgo
298325ginkgo : $(GINKGO ) # # Install ginkgo
299326$(GINKGO ) : $(LOCALBIN )
300- $(call install- go-tool -mod,$(LOCALBIN ) ,$(GINKGO_URL ) )
327+ $(call go-install -mod-tool ,$(LOCALBIN ) ,$(GINKGO_URL ) )
301328
302329
303330.PHONY : kustomize
304331KUSTOMIZE = $(LOCALBIN ) /kustomize
305332KUSTOMIZE_URL := sigs.k8s.io/kustomize/kustomize/$(KUSTOMIZE_MAJOR ) @$(KUSTOMIZE_VERSION )
306333kustomize : $(KUSTOMIZE ) # # Download kustomize locally if necessary.
307334$(KUSTOMIZE ) : $(LOCALBIN )
308- $(call install-go -tool,$(LOCALBIN ) ,$(KUSTOMIZE_URL ) )
335+ $(call go-install -tool,$(LOCALBIN ) ,$(KUSTOMIZE_URL ) )
309336
310337.PHONY : helm
311338HELM := $(LOCALBIN ) /helm
0 commit comments