Created
June 20, 2023 07:42
-
-
Save chendotjs/74e23a0e6bce9e2db4215d75f89b722c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
VERSION=${1#"v"} | |
if [ -z "$VERSION" ]; then | |
echo "Please specify the Kubernetes version: e.g." | |
echo "./download-deps.sh v1.21.0" | |
exit 1 | |
fi | |
set -euo pipefail | |
# Find out all the replaced imports, make a list of them. | |
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' | |
)) | |
# Now add those similar replace statements in the local go.mod file, but first find the version that | |
# the Kubernetes is using for them. | |
for MOD in "${MODS[@]}"; do | |
V=$( | |
go mod download -json "${MOD}@kubernetes-${VERSION}" | | |
sed -n 's|.*"Version": "\(.*\)".*|\1|p' | |
) | |
go mod edit "-replace=${MOD}=${MOD}@${V}" | |
done | |
go get "k8s.io/kubernetes@v${VERSION}" | |
go mod download |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment