Skip to content

Commit 5b1de1a

Browse files
committed
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.
1 parent 49b4269 commit 5b1de1a

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Diff for: go-get-kubernetes.sh

+6
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ mods=$( (set -x; curl --silent --show-error --fail "https://raw.githubuserconten
5555
sed -n 's|.*k8s.io/\(.*\) => ./staging/src/k8s.io/.*|k8s.io/\1|p'
5656
) || die "failed to determine Kubernetes staging modules"
5757
for mod in $mods; do
58+
if ! (env GO111MODULE=on go mod graph) | grep "$mod@" > /dev/null; then
59+
echo "Kubernetes module $mod is not used, skipping"
60+
# Remove the module from go.mod "replace" that was added by an older version of this script.
61+
(set -x; env GO111MODULE=on go mod edit "-dropreplace=$mod") || die "'go mod edit' failed"
62+
continue
63+
fi
5864
# The presence of a potentially incomplete go.mod file affects this command,
5965
# so move elsewhere.
6066
modinfo=$(set -x; cd /; env GO111MODULE=on go mod download -json "$mod@kubernetes-${k8s}") ||

0 commit comments

Comments
 (0)