Skip to content

Commit

Permalink
Extend update-deps.sh so that we can automatically update k8s librari…
Browse files Browse the repository at this point in the history
…es in the apis pkg

Signed-off-by: Yuki Iwai <yuki.iwai.tz@gmail.com>
  • Loading branch information
tenzen-y committed Mar 2, 2024
1 parent ac2d581 commit 4c15854
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 18 deletions.
3 changes: 2 additions & 1 deletion cluster-autoscaler/hack/update-codegen.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ set -o pipefail

SCRIPT_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}"))/..
CODEGEN_PKG="../vendor/k8s.io/code-generator"
cd "${SCRIPT_ROOT}/apis"
pushd "${SCRIPT_ROOT}/apis"

chmod +x "${CODEGEN_PKG}"/generate-groups.sh
chmod +x "${CODEGEN_PKG}"/generate-internal-groups.sh
Expand All @@ -38,3 +38,4 @@ bash "${CODEGEN_PKG}"/generate-groups.sh "applyconfiguration,client,deepcopy,inf

chmod -x "${CODEGEN_PKG}"/generate-groups.sh
chmod -x "${CODEGEN_PKG}"/generate-internal-groups.sh
popd
44 changes: 27 additions & 17 deletions cluster-autoscaler/hack/update-deps.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,32 @@ MODS=($(
popd
rm -rf ${WORKDIR}

for MOD in "${MODS[@]}"; do
V=$(
GOMOD="${MOD}@kubernetes-${VERSION}"
JSON=$(go mod download -json "${GOMOD}")
retval=$?
if [ $retval -ne 0 ]; then
echo "Error downloading module ${GOMOD}."
exit 1
fi
echo "${JSON}" | sed -n 's|.*"Version": "\(.*\)".*|\1|p'
)
go mod edit "-replace=${MOD}=${MOD}@${V}"
PKGS=("." "./apis")
for pkg in "${PKGS[@]}"; do
pushd "${pkg}"

for MOD in "${MODS[@]}"; do
V=$(
GOMOD="${MOD}@kubernetes-${VERSION}"
JSON=$(go mod download -json "${GOMOD}")
retval=$?
if [ $retval -ne 0 ]; then
echo "Error downloading module ${GOMOD}."
exit 1
fi
echo "${JSON}" | sed -n 's|.*"Version": "\(.*\)".*|\1|p'
)
go mod edit "-replace=${MOD}=${MOD}@${V}"
done

go get "k8s.io/kubernetes@v${VERSION}"
go mod tidy
if [ "$(pkg)" = "." ]; then \
go mod vendor
sed -i "s|\(const ClusterAutoscalerVersion = \)\".*\"|\1\"$VERSION\"|" version/version.go
fi
git rm -r --force --ignore-unmatch kubernetes

popd
done
go get "k8s.io/kubernetes@v${VERSION}"
go mod tidy
go mod vendor
git rm -r --force --ignore-unmatch kubernetes

sed -i "s|\(const ClusterAutoscalerVersion = \)\".*\"|\1\"$VERSION\"|" version/version.go

0 comments on commit 4c15854

Please sign in to comment.