Skip to content

Commit

Permalink
Backport of [NET-6741] make: Add target for updating dependencies acr…
Browse files Browse the repository at this point in the history
…oss all modules into release/1.4.x (#450)

backport of commit d2111b8

Co-authored-by: Michael Zalimeni <michael.zalimeni@hashicorp.com>
  • Loading branch information
hc-github-team-consul-core and zalimeni authored Feb 21, 2024
1 parent 56fb92d commit 0ceca4d
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ BIN_NAME ?= $(PRODUCT_NAME)
GOPATH ?= $(shell go env GOPATH)
GOBIN ?= $(GOPATH)/bin

GO_MODULES := $(shell find . -name go.mod -exec dirname {} \; | sort)

# Get local ARCH; on Intel Mac, 'uname -m' returns x86_64 which we turn into amd64.
# Not using 'go env GOOS/GOARCH' here so 'make docker' will work without local Go install.
ARCH ?= $(shell A=$$(uname -m); [ $$A = x86_64 ] && A=amd64; echo $$A)
Expand Down Expand Up @@ -158,6 +160,19 @@ mocks:
mockery --srcpkg=github.com/hashicorp/consul/proto-public/$$pkg --output ./internal/mocks/$${pkg}mock --outpkg $${pkg}mock --case underscore --all; \
done

.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 <dependency>@<version>, 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

##@ Help

# The help target prints out all targets with their descriptions organized
Expand Down

0 comments on commit 0ceca4d

Please sign in to comment.