Skip to content

Commit 5b87eb5

Browse files
committed
Add go mod replace when proto changes happen
Signed-off-by: Derek McGowan <[email protected]> (cherry picked from commit e69efd5) Signed-off-by: Derek McGowan <[email protected]>
1 parent a3a7431 commit 5b87eb5

1 file changed

Lines changed: 9 additions & 1 deletion

File tree

Makefile

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ GOTEST ?= $(GO) test
149149
OUTPUTDIR = $(join $(ROOTDIR), _output)
150150
CRIDIR=$(OUTPUTDIR)/cri
151151

152-
.PHONY: clean all AUTHORS build binaries test integration generate protos check-protos coverage ci check help install uninstall vendor release static-release mandir install-man genman install-cri-deps cri-release cri-cni-release cri-integration install-deps bin/cri-integration.test
152+
.PHONY: clean all AUTHORS build binaries test integration generate protos check-protos coverage ci check help install uninstall vendor release static-release mandir install-man genman install-cri-deps cri-release cri-cni-release cri-integration install-deps bin/cri-integration.test remove-replace clean-vendor
153153
.DEFAULT: default
154154

155155
# Forcibly set the default goal to all, in case an include above brought in a rule definition.
@@ -180,6 +180,8 @@ protos: bin/protoc-gen-go-fieldpath
180180
@mv ${TMPDIR}/vendor ${ROOTDIR}
181181
@rm -rf ${TMPDIR}
182182
go-fix-acronym -w -a '(Id|Io|Uuid|Os)$$' $(shell find api/ runtime/ -name '*.pb.go')
183+
@test -z "$$(git status --short | grep "api/next.pb.txt" | tee /dev/stderr)" || \
184+
$(GO) mod edit -replace=github.com/containerd/containerd/api=./api
183185

184186
check-protos: protos ## check if protobufs needs to be generated again
185187
@echo "$(WHALE) $@"
@@ -470,6 +472,10 @@ root-coverage: ## generate coverage profiles for unit tests that require root
470472
fi; \
471473
done )
472474

475+
remove-replace:
476+
@echo "$(WHALE) $@"
477+
@$(GO) mod edit -dropreplace=github.com/containerd/containerd/api
478+
473479
vendor: ## ensure all the go.mod/go.sum files are up-to-date including vendor/ directory
474480
@echo "$(WHALE) $@"
475481
@$(GO) mod tidy
@@ -489,6 +495,8 @@ verify-vendor: ## verify if all the go.mod/go.sum files are up-to-date
489495
@rm -rf ${TMPDIR}
490496
@${ROOTDIR}/script/verify-go-modules.sh integration/client
491497

498+
clean-vendor: remove-replace vendor
499+
492500

493501
help: ## this help
494502
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) | sort

0 commit comments

Comments
 (0)