Skip to content

Commit e69efd5

Browse files
committed
Add go mod replace when proto changes happen
Signed-off-by: Derek McGowan <[email protected]>
1 parent 114ef75 commit e69efd5

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Makefile

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

153-
.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 install-doc genman install-cri-deps cri-release cri-cni-release cri-integration install-deps bin/cri-integration.test
153+
.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 install-doc genman install-cri-deps cri-release cri-cni-release cri-integration install-deps bin/cri-integration.test remove-replace clean-vendor
154154
.DEFAULT: default
155155

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

185187
check-protos: protos ## check if protobufs needs to be generated again
186188
@echo "$(WHALE) $@"
@@ -466,6 +468,10 @@ root-coverage: ## generate coverage profiles for unit tests that require root
466468
fi; \
467469
done )
468470

471+
remove-replace:
472+
@echo "$(WHALE) $@"
473+
@$(GO) mod edit -dropreplace=github.com/containerd/containerd/api
474+
469475
vendor: ## ensure all the go.mod/go.sum files are up-to-date including vendor/ directory
470476
@echo "$(WHALE) $@"
471477
@$(GO) mod tidy
@@ -484,6 +490,8 @@ verify-vendor: ## verify if all the go.mod/go.sum files are up-to-date
484490
@diff -r -u -q ${ROOTDIR} ${TMPDIR}/containerd
485491
@rm -rf ${TMPDIR}
486492

493+
clean-vendor: remove-replace vendor
494+
487495

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

0 commit comments

Comments
 (0)