From 369f8b7c8ccd96b872c1784d0c2a7ea71fba7c18 Mon Sep 17 00:00:00 2001 From: Artur Troian Date: Mon, 22 Jan 2024 10:57:34 -0500 Subject: [PATCH] build: bind mockery into go mod (#173) Signed-off-by: Artur Troian --- go.mod | 1 + go.sum | 2 ++ make/init.mk | 4 ++-- make/setup-cache.mk | 2 +- tools.go | 1 + 5 files changed, 7 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 922a044f..b7d7bb50 100644 --- a/go.mod +++ b/go.mod @@ -28,6 +28,7 @@ require ( github.com/spf13/viper v1.16.0 github.com/stretchr/testify v1.8.4 github.com/tendermint/tendermint v0.34.27 + github.com/vektra/mockery/v2 v2.40.1 go.uber.org/zap v1.24.0 golang.org/x/net v0.14.0 golang.org/x/sync v0.3.0 diff --git a/go.sum b/go.sum index b3cf62aa..df73b1df 100644 --- a/go.sum +++ b/go.sum @@ -1893,6 +1893,8 @@ github.com/valyala/fasttemplate v1.0.1/go.mod h1:UQGH1tvbgY+Nz5t2n7tXsz52dQxojPU github.com/valyala/fasttemplate v1.2.1/go.mod h1:KHLXt3tVN2HBp8eijSv/kGJopbvo7S+qRAEEKiv+SiQ= github.com/valyala/tcplisten v0.0.0-20161114210144-ceec8f93295a/go.mod h1:v3UYOV9WzVtRmSR+PDvWpU/qWl4Wa5LApYYX4ZtKbio= github.com/vektah/gqlparser v1.1.2/go.mod h1:1ycwN7Ij5njmMkPPAOaRFY4rET2Enx7IkVv3vaXspKw= +github.com/vektra/mockery/v2 v2.14.0 h1:KZ1p5Hrn8tiY+LErRMr14HHle6khxo+JKOXLBW/yfqs= +github.com/vektra/mockery/v2 v2.14.0/go.mod h1:bnD1T8tExSgPD1ripLkDbr60JA9VtQeu12P3wgLZd7M= github.com/vmihailenco/msgpack/v5 v5.3.5/go.mod h1:7xyJ9e+0+9SaZT0Wt1RGleJXzli6Q/V5KbhBonMG9jc= github.com/vmihailenco/tagparser/v2 v2.0.0/go.mod h1:Wri+At7QHww0WTrCBeu4J6bNtoV6mEfg5OIWRZA9qds= github.com/vmware/govmomi v0.18.0 h1:f7QxSmP7meCtoAmiKZogvVbLInT+CZx6Px6K5rYsJZo= diff --git a/make/init.mk b/make/init.mk index 182b1e44..62e70859 100644 --- a/make/init.mk +++ b/make/init.mk @@ -88,10 +88,10 @@ AKASHD_LOCAL_PATH := $(shell $(GO) list -mod=readonly -m -f '{{ .Dir AKASHD_VERSION := $(shell $(GO) list -mod=readonly -m -f '{{ .Version }}' $(AKASHD_MODULE) | cut -c2-) GRPC_GATEWAY_VERSION := $(shell $(GO) list -mod=readonly -m -f '{{ .Version }}' github.com/grpc-ecosystem/grpc-gateway) GOLANGCI_LINT_VERSION ?= v1.51.2 -GOLANG_VERSION ?= 1.16.1 STATIK_VERSION ?= v0.1.7 GIT_CHGLOG_VERSION ?= v0.15.1 -MOCKERY_VERSION ?= 2.32.0 +MOCKERY_PACKAGE_NAME := github.com/vektra/mockery/v2 +MOCKERY_VERSION ?= $(shell $(GO) list -mod=readonly -m -f '{{ .Version }}' $(MOCKERY_PACKAGE_NAME)) K8S_CODE_GEN_VERSION ?= $(shell $(GO) list -mod=readonly -m -f '{{ .Version }}' k8s.io/code-generator) AKASHD_BUILD_FROM_SRC := false diff --git a/make/setup-cache.mk b/make/setup-cache.mk index ea61004b..6697b605 100644 --- a/make/setup-cache.mk +++ b/make/setup-cache.mk @@ -70,7 +70,7 @@ $(GIT_CHGLOG): $(GIT_CHGLOG_VERSION_FILE) $(MOCKERY_VERSION_FILE): $(AP_DEVCACHE) @echo "installing mockery $(MOCKERY_VERSION) ..." rm -f $(MOCKERY) - GOBIN=$(AP_DEVCACHE_BIN) go install -ldflags '-s -w -X github.com/vektra/mockery/v2/pkg/config.SemVer=$(MOCKERY_VERSION)' github.com/vektra/mockery/v2@v$(MOCKERY_VERSION) + GOBIN=$(AP_DEVCACHE_BIN) go install -ldflags '-s -w -X $(MOCKERY_PACKAGE_NAME)/pkg/config.SemVer=$(MOCKERY_VERSION)' $(MOCKERY_PACKAGE_NAME)@$(MOCKERY_VERSION) rm -rf "$(dir $@)" mkdir -p "$(dir $@)" touch $@ diff --git a/tools.go b/tools.go index f1e8ed9e..4077faf6 100644 --- a/tools.go +++ b/tools.go @@ -4,6 +4,7 @@ package tools // nolint import ( + _ "github.com/vektra/mockery/v2" _ "k8s.io/code-generator" _ "sigs.k8s.io/kind" )