From 5b1de1adbac74ebf3c5e9155eccdfedccc042dd8 Mon Sep 17 00:00:00 2001 From: Jan Safranek Date: Wed, 14 Apr 2021 10:14:52 +0200 Subject: [PATCH] go-get-kubernetes.sh: remove unused k8s libs go-get-kubernetes.sh should not add all Kubernetes libraries to "replace" section, only those that are actually used. --- go-get-kubernetes.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/go-get-kubernetes.sh b/go-get-kubernetes.sh index 8c4e3024..cbbbb7c3 100755 --- a/go-get-kubernetes.sh +++ b/go-get-kubernetes.sh @@ -55,6 +55,12 @@ mods=$( (set -x; curl --silent --show-error --fail "https://raw.githubuserconten sed -n 's|.*k8s.io/\(.*\) => ./staging/src/k8s.io/.*|k8s.io/\1|p' ) || die "failed to determine Kubernetes staging modules" for mod in $mods; do + if ! (env GO111MODULE=on go mod graph) | grep "$mod@" > /dev/null; then + echo "Kubernetes module $mod is not used, skipping" + # Remove the module from go.mod "replace" that was added by an older version of this script. + (set -x; env GO111MODULE=on go mod edit "-dropreplace=$mod") || die "'go mod edit' failed" + continue + fi # The presence of a potentially incomplete go.mod file affects this command, # so move elsewhere. modinfo=$(set -x; cd /; env GO111MODULE=on go mod download -json "$mod@kubernetes-${k8s}") ||