diff --git a/Makefile b/Makefile index 230fbd88..93381398 100644 --- a/Makefile +++ b/Makefile @@ -399,7 +399,15 @@ dev-azure-nuke: envsubst azure-nuke ## Warning: Destructive! Nuke all Azure reso @rm config/dev/azure-cloud-nuke.yaml .PHONY: cli-install -cli-install: clusterawsadm clusterctl cloud-nuke envsubst yq awscli ## Install the necessary CLI tools for deployment, development and testing. +cli-install: clusterawsadm clusterctl cloud-nuke envsubst yq awscli jq## Install the necessary CLI tools for deployment, development and testing. + @required_bins="clusterawsadm clusterctl cloud-nuke envsubst yq aws jq"; \ + for bin in $$required_bins; do \ + if ! command -v $$bin >/dev/null 2>&1; then \ + $$bin ; \ + echo "Error: '$$bin' is not installed or not in your PATH. Exiting."; \ + exit 1; \ + fi; \ + done ##@ Dependencies @@ -413,13 +421,13 @@ EXTERNAL_CRD_DIR ?= $(LOCALBIN)/crd $(EXTERNAL_CRD_DIR): $(LOCALBIN) mkdir -p $(EXTERNAL_CRD_DIR) -FLUX_SOURCE_VERSION ?= $(shell go mod edit -json | jq -r '.Require[] | select(.Path == "github.com/fluxcd/source-controller/api") | .Version') +FLUX_SOURCE_VERSION ?= $(shell go mod edit -json | $(JQ) -r '.Require[] | select(.Path == "github.com/fluxcd/source-controller/api") | .Version') FLUX_SOURCE_REPO_NAME ?= source-helmrepositories FLUX_SOURCE_REPO_CRD ?= $(EXTERNAL_CRD_DIR)/$(FLUX_SOURCE_REPO_NAME)-$(FLUX_SOURCE_VERSION).yaml FLUX_SOURCE_CHART_NAME ?= source-helmchart FLUX_SOURCE_CHART_CRD ?= $(EXTERNAL_CRD_DIR)/$(FLUX_SOURCE_CHART_NAME)-$(FLUX_SOURCE_VERSION).yaml -FLUX_HELM_VERSION ?= $(shell go mod edit -json | jq -r '.Require[] | select(.Path == "github.com/fluxcd/helm-controller/api") | .Version') +FLUX_HELM_VERSION ?= $(shell go mod edit -json | $(JQ) -r '.Require[] | select(.Path == "github.com/fluxcd/helm-controller/api") | .Version') FLUX_HELM_NAME ?= helm FLUX_HELM_CRD ?= $(EXTERNAL_CRD_DIR)/$(FLUX_HELM_NAME)-$(FLUX_HELM_VERSION).yaml @@ -441,6 +449,8 @@ export HELM KIND ?= $(LOCALBIN)/kind-$(KIND_VERSION) YQ ?= $(LOCALBIN)/yq-$(YQ_VERSION) export YQ +JQ ?= $(LOCALBIN)/jq-$(JQ_VERSION) +export JQ CLUSTERAWSADM ?= $(LOCALBIN)/clusterawsadm CLUSTERCTL ?= $(LOCALBIN)/clusterctl export CLUSTERCTL @@ -458,6 +468,7 @@ GOLANGCI_LINT_TIMEOUT ?= 1m HELM_VERSION ?= v3.15.1 KIND_VERSION ?= v0.23.0 YQ_VERSION ?= v4.44.2 +JQ_VERSION ?= 1.7.1 CLOUDNUKE_VERSION = v0.37.1 AZURENUKE_VERSION = v1.1.0 CLUSTERAWSADM_VERSION ?= v2.5.2 @@ -524,6 +535,16 @@ yq: $(YQ) ## Download yq locally if necessary. $(YQ): | $(LOCALBIN) $(call go-install-tool,$(YQ),github.com/mikefarah/yq/v4,${YQ_VERSION}) +.PHONY: jq +jq: $(JQ) ## Download jq locally if necessary. +$(JQ): | $(LOCALBIN) + @if [ $(HOSTOS) == "darwin" ]; then \ + curl -sL --fail https://github.com/jqlang/jq/releases/download/jq-$(JQ_VERSION)/jq-macos-$(HOSTARCH) -o $(JQ); \ + else \ + curl -sL --fail https://github.com/jqlang/jq/releases/download/jq-$(JQ_VERSION)/jq-$(HOSTOS)-$(HOSTARCH) -o $(JQ); \ + fi; \ + chmod +x $(JQ) + .PHONY: cloud-nuke cloud-nuke: $(CLOUDNUKE) ## Download cloud-nuke locally if necessary. $(CLOUDNUKE): | $(LOCALBIN)