Skip to content

Commit

Permalink
restore go-get-tool function in Makefile and use to go install envtes…
Browse files Browse the repository at this point in the history
…t and controller-gen

Signed-off-by: Michael Valdron <[email protected]>
  • Loading branch information
michael-valdron committed Aug 29, 2023
1 parent ff11084 commit f7b6524
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ uninstall-cert:
controller-gen: $(CONTROLLER_GEN)
$(CONTROLLER_GEN): $(LOCALBIN)
test -s $(LOCALBIN)/controller-gen && $(LOCALBIN)/controller-gen --version | grep -q $(CONTROLLER_TOOLS_VERSION) || \
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
$(call go-get-tool,sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION))

##@ Deployment

Expand Down Expand Up @@ -219,7 +219,19 @@ $(KUSTOMIZE): $(LOCALBIN)
.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
test -s $(LOCALBIN)/setup-envtest || $(call go-get-tool,sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)

# go-get-tool will 'go install' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(1)" ;\
GOBIN=$(LOCALBIN) go install $(1) ;\
rm -rf $$TMP_DIR ;
endef

# Generate bundle manifests and metadata, then validate generated files.
.PHONY: bundle
Expand Down

0 comments on commit f7b6524

Please sign in to comment.