From a267cbfc038c87e14b87e4153ccb34b7ed3c4911 Mon Sep 17 00:00:00 2001 From: Michael Zalimeni Date: Wed, 21 Feb 2024 16:15:03 +0000 Subject: [PATCH] backport of commit 44583d3a441c882a99893c7b037a0d3bbd691327 --- Makefile | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Makefile b/Makefile index a3ee7da944..bb665fc5e7 100644 --- a/Makefile +++ b/Makefile @@ -7,6 +7,8 @@ KIND_VERSION= $(shell ./control-plane/build-support/scripts/read-yaml-config.sh KIND_NODE_IMAGE= $(shell ./control-plane/build-support/scripts/read-yaml-config.sh acceptance/ci-inputs/kind-inputs.yaml .kindNodeImage) KUBECTL_VERSION= $(shell ./control-plane/build-support/scripts/read-yaml-config.sh acceptance/ci-inputs/kind-inputs.yaml .kubectlVersion) +GO_MODULES := $(shell find . -name go.mod -exec dirname {} \; | sort) + ##@ Helm Targets .PHONY: gen-helm-docs @@ -317,6 +319,19 @@ go-mod-tidy: ## Recursively run go mod tidy on all subdirectories check-mod-tidy: ## Recursively run go mod tidy on all subdirectories and check if there are any changes @./control-plane/build-support/scripts/mod_tidy.sh --check +.PHONY: go-mod-get +go-mod-get: $(foreach mod,$(GO_MODULES),go-mod-get/$(mod)) ## Run go get and go mod tidy in every module for the given dependency + +.PHONY: go-mod-get/% +go-mod-get/%: +ifndef DEP_VERSION + $(error DEP_VERSION is undefined: set this to @, e.g. github.com/hashicorp/go-hclog@v1.5.0) +endif + @echo "--> Running go get ${DEP_VERSION} ($*)" + @cd $* && go get $(DEP_VERSION) + @echo "--> Running go mod tidy ($*)" + @cd $* && go mod tidy + ##@ Release Targets .PHONY: check-env