Skip to content

Commit

Permalink
improve Makefile
Browse files Browse the repository at this point in the history
    - add jq to tools to be installed with make cli-install
    - exit with Error if a binary is not found

Signed-off-by: Satyam Bhardwaj <[email protected]>
  • Loading branch information
ramessesii2 committed Dec 29, 2024
1 parent 074f989 commit 725573c
Showing 1 changed file with 24 additions and 3 deletions.
27 changes: 24 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 725573c

Please sign in to comment.