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 9, 2024
1 parent bd32754 commit 108385e
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
7 changes: 4 additions & 3 deletions cluster-autoscaler/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@ require (
github.com/google/uuid v1.6.0
github.com/jmespath/go-jmespath v0.4.0
github.com/json-iterator/go v1.1.12
github.com/onsi/ginkgo/v2 v2.15.0
github.com/onsi/gomega v1.31.0
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.16.0
github.com/spf13/pflag v1.0.5
Expand All @@ -41,10 +39,10 @@ require (
k8s.io/api v0.30.0-alpha.3
k8s.io/apimachinery v0.30.0-alpha.3
k8s.io/apiserver v0.30.0-alpha.3
k8s.io/autoscaler/cluster-autoscaler/apis v0.0.0-00010101000000-000000000000
k8s.io/client-go v0.30.0-alpha.3
k8s.io/cloud-provider v0.30.0-alpha.3
k8s.io/cloud-provider-aws v1.27.0
k8s.io/code-generator v0.30.0-alpha.3
k8s.io/component-base v0.30.0-alpha.3
k8s.io/component-helpers v0.30.0-alpha.3
k8s.io/klog/v2 v2.120.1
Expand Down Expand Up @@ -134,6 +132,8 @@ require (
github.com/mrunalp/fileutils v0.5.1 // indirect
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
github.com/mxk/go-flowrate v0.0.0-20140419014527-cca7078d478f // indirect
github.com/onsi/ginkgo/v2 v2.15.0 // indirect
github.com/onsi/gomega v1.31.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/runc v1.1.12 // indirect
github.com/opencontainers/runtime-spec v1.0.3-0.20220909204839-494a5a6aca78 // indirect
Expand Down Expand Up @@ -195,6 +195,7 @@ require (
k8s.io/mount-utils v0.26.0-alpha.0 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.29.0 // indirect
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
)

replace github.com/aws/aws-sdk-go/service/eks => github.com/aws/aws-sdk-go/service/eks v1.38.49
Expand Down
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 108385e

Please sign in to comment.