chore: add the script of updating k8s version

Signed-off-by: ZeroMagic <jiliu8@microsoft.com>
This commit is contained in:
ZeroMagic 2020-04-14 02:20:37 +00:00
parent 67373d45a3
commit 279d55a3e4
1 changed files with 21 additions and 0 deletions

21
hack/update-gomod.sh Executable file
View File

@ -0,0 +1,21 @@
#!/bin/sh
set -euo pipefail
VERSION=${1#"v"}
if [ -z "$VERSION" ]; then
echo "Must specify version!"
exit 1
fi
MODS=($(
curl -sS https://raw.githubusercontent.com/kubernetes/kubernetes/v${VERSION}/go.mod |
sed -n 's|.*k8s.io/\(.*\) => ./staging/src/k8s.io/.*|k8s.io/\1|p'
))
for MOD in "${MODS[@]}"; do
echo $MOD
V=$(
go mod download -json "${MOD}@kubernetes-${VERSION}" |
sed -n 's|.*"Version": "\(.*\)".*|\1|p'
)
echo ${V}
go mod edit "-replace=${MOD}=${MOD}@${V}"
done