Skip to content

Commit

Permalink
chore: check and install controller-gen as required version (#5344)
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-inf authored Oct 9, 2023
1 parent ea321d0 commit 87a6d4c
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -490,12 +490,15 @@ ifeq (, $(shell ls $(LOCALBIN)/kustomize 2>/dev/null))
endif

.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
$(CONTROLLER_GEN): $(LOCALBIN)
ifeq (, $(shell ls $(LOCALBIN)/controller-gen 2>/dev/null))
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)
endif

controller-gen: $(LOCALBIN) ## Download controller-gen locally if necessary.
@{ \
set -e ;\
if [ ! -f "$(CONTROLLER_GEN)" ] || [ "$$($(CONTROLLER_GEN) --version 2>&1 | awk '{print $$NF}')" != "$(CONTROLLER_TOOLS_VERSION)" ]; then \
echo 'Installing controller-gen@$(CONTROLLER_TOOLS_VERSION)...' ;\
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION) ;\
echo 'Successfully installed' ;\
fi \
}

.PHONY: envtest
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
Expand All @@ -504,7 +507,6 @@ ifeq (, $(shell ls $(LOCALBIN)/setup-envtest 2>/dev/null))
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
endif


.PHONY: install-docker-buildx
install-docker-buildx: ## Create `docker buildx` builder.
@if ! docker buildx inspect $(BUILDX_BUILDER) > /dev/null; then \
Expand All @@ -514,7 +516,6 @@ install-docker-buildx: ## Create `docker buildx` builder.
echo "Buildx builder $(BUILDX_BUILDER) already exists"; \
fi


.PHONY: golangci
golangci: GOLANGCILINT_VERSION = v1.51.2
golangci: ## Download golangci-lint locally if necessary.
Expand Down

0 comments on commit 87a6d4c

Please sign in to comment.