Skip to content

Commit 40b0ccf

Browse files
committed
fix makefile targets
Signed-off-by: Oleg <97077423+RobotSail@users.noreply.github.com>
1 parent 132605e commit 40b0ccf

File tree

1 file changed

+30
-3
lines changed

1 file changed

+30
-3
lines changed

Makefile

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,38 @@ TMP_DIR=$$(mktemp -d) ;\
212212
cd $$TMP_DIR ;\
213213
go mod init tmp ;\
214214
echo "Downloading $(2)" ;\
215-
GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
215+
GOBIN=$(LOCALBIN) go get $(2) ;\
216216
rm -rf $$TMP_DIR ;\
217217
}
218218
endef
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
221248
bundle: 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
297324
GINKGO_URL := github.com/onsi/ginkgo/v2/ginkgo
298325
ginkgo: $(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
304331
KUSTOMIZE = $(LOCALBIN)/kustomize
305332
KUSTOMIZE_URL := sigs.k8s.io/kustomize/kustomize/$(KUSTOMIZE_MAJOR)@$(KUSTOMIZE_VERSION)
306333
kustomize: $(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
311338
HELM := $(LOCALBIN)/helm

0 commit comments

Comments
 (0)