From f1252c7ed1136124aa92e8d6bcba2899e8e35ca8 Mon Sep 17 00:00:00 2001 From: Daniel Lipovetsky Date: Mon, 18 Dec 2023 09:10:27 -0800 Subject: [PATCH] Add clusterctl to local set of tools --- Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Makefile b/Makefile index 96baf5ae59..f29148279b 100644 --- a/Makefile +++ b/Makefile @@ -123,6 +123,12 @@ GOLANGCI_LINT_VER := v1.55.2 GOLANGCI_LINT_BIN := golangci-lint GOLANGCI_LINT := $(abspath $(TOOLS_BIN_DIR)/$(GOLANGCI_LINT_BIN)) +# Install clusterctl that corresponds to the cluster-api go mod version +CLUSTERCTL_VER := $(shell go list -m sigs.k8s.io/cluster-api | cut -d" " -f2) +CLUSTERCTL_RELEASE_URL := https://github.com/kubernetes-sigs/cluster-api/releases/download/$(CLUSTERCTL_VER)/clusterctl-$(shell go env GOOS)-$(shell go env GOARCH) +CLUSTERCTL_BIN := clusterctl +CLUSTERCTL := $(abspath $(TOOLS_BIN_DIR)/$(CLUSTERCTL_BIN)) + # CRD_OPTIONS define options to add to the CONTROLLER_GEN CRD_OPTIONS ?= "crd:crdVersions=v1" @@ -529,6 +535,9 @@ $(TILT_PREPARE_BIN): $(TILT_PREPARE) ## Build a local copy of tilt-prepare. .PHONY: $(GOLANGCI_LINT_BIN) $(GOLANGCI_LINT_BIN): $(GOLANGCI_LINT) ## Build a local copy of golangci-lint +.PHONY: $(CLUSTERCTL_BIN) +$(CLUSTERCTL_BIN): $(CLUSTERCTL) ## Build a local copy of clusterctl + $(GINKGO): # Build ginkgo from tools folder. GOBIN=$(TOOLS_BIN_DIR) $(GO_INSTALL) $(GINKGO_PKG) $(GINKGO_BIN) $(GINGKO_VER) @@ -580,6 +589,12 @@ $(KPROMO): $(GOLANGCI_LINT): # building golanci-lint from source is not recommended, so we are using the install script curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(TOOLS_BIN_DIR) $(GOLANGCI_LINT_VER) +$(CLUSTERCTL): +# We don't install clusterctl using the go toolchain, because the upstream Makefile +# is required to build clusterctl correctly. See https://github.com/kubernetes-sigs/cluster-api/issues/3706 + curl -sSfL -o $(CLUSTERCTL) $(CLUSTERCTL_RELEASE_URL) + chmod u+x $(CLUSTERCTL) + ## -------------------------------------- ## Lint / Verify ## --------------------------------------