...
1#!/bin/bash
2
3set -e
4
5VERSION=$(cat hack/deps/.k8s-version)
6
7# shellcheck disable=SC2207
8# Prefer mapfile or read -a to split command output (or quote to avoid splitting)
9# TODO: Next author should verify current behavior is correct. If so, keep shellcheck
10# disabled, otherwise update according to recommendation
11MODS=($(
12 curl -sS "https://raw.githubusercontent.com/kubernetes/kubernetes/v${VERSION}/go.mod" |
13 sed -n 's|.*k8s.io/\(.*\) => ./staging/src/k8s.io/.*|k8s.io/\1|p'
14))
15
16for MOD in "${MODS[@]}"; do
17 V=$(
18 go mod download -json "${MOD}@kubernetes-${VERSION}" |
19 sed -n 's|.*"Version": "\(.*\)".*|\1|p'
20 )
21 if grep -F "${MOD}" go.mod
22 then
23 go mod edit "-replace=${MOD}=${MOD}@${V}"
24 fi
25done
26go get "k8s.io/kubernetes@v${VERSION}"
View as plain text