Skip to content

Commit

Permalink
Add Script to Update K8s Deps
Browse files Browse the repository at this point in the history
Followup from reading through
kubernetes/kubernetes#90358

Signed-off-by: astoycos <astoycos@redhat.com>
  • Loading branch information
astoycos committed Aug 29, 2022
1 parent d009b6c commit f60aaad
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 0 deletions.
6 changes: 6 additions & 0 deletions Makefile
Expand Up @@ -135,3 +135,9 @@ build:
./...
@echo "\tkpng $(YELLOW)$(PLATFORM)$(RESET) binaries available in: $(GREEN)$(BUILD_DIR)/$(PLATFORM)/$(VERSION)$(RESET)\n"

# See https://github.com/kubernetes/kubernetes/issues/79384 for the backstory
update-k8s-mod:
@read -p "Enter K8s version:" version; \
./hack/change-k8s-ver-mod.sh $$version


20 changes: 20 additions & 0 deletions hack/change-k8s-ver-mod.sh
@@ -0,0 +1,20 @@
#!/bin/bash
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
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}"

0 comments on commit f60aaad

Please sign in to comment.