diff --git a/Makefile b/Makefile index 1a1aaff581..2acd9fe76b 100644 --- a/Makefile +++ b/Makefile @@ -152,7 +152,9 @@ functions-examples-all: done test-go-mod: - ./hack/for-each-module.sh "go list -m -json all > /dev/null && go mod tidy -v" + ./hack/for-each-module.sh $$(pwd)/hack/replace.sh; \ + ./hack/for-each-module.sh "go mod tidy -v"; \ + ./hack/for-each-module.sh $$(pwd)/hack/dropReplace.sh .PHONY: verify-kustomize-e2e: $(MYGOBIN)/mdrip $(MYGOBIN)/kind diff --git a/hack/dropReplace.sh b/hack/dropReplace.sh new file mode 100755 index 0000000000..47603464b5 --- /dev/null +++ b/hack/dropReplace.sh @@ -0,0 +1,9 @@ +#!/usr/bin/env bash +# Copyright 2023 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +read -a modules <<< $(go list -m) + +for i in ${!modules[@]}; do + go mod edit -dropreplace=${modules[i]} +done \ No newline at end of file diff --git a/hack/replace.sh b/hack/replace.sh new file mode 100755 index 0000000000..04e42b110a --- /dev/null +++ b/hack/replace.sh @@ -0,0 +1,14 @@ +#!/usr/bin/env bash +# Copyright 2023 The Kubernetes Authors. +# SPDX-License-Identifier: Apache-2.0 + +read -a modules <<< $(go list -m) +read -a module_paths <<< $(go list -m -f {{.Dir}}) + +for i in ${!modules[@]}; do + replace_path=$(realpath --relative-to=$(pwd) ${module_paths[i]}) + if [ $replace_path == . ]; then + continue + fi + go mod edit -replace=${modules[i]}=$replace_path +done \ No newline at end of file