Skip to content

Commit

Permalink
[#1408] add fetch-kubernetes-hash script
Browse files Browse the repository at this point in the history
  • Loading branch information
yjqg6666 committed Jul 27, 2022
1 parent 38897fe commit ca94e5d
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions hack/fetch-kubernetes-hash.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/bin/bash

v22_patch_max=12
v23_patch_max=9
v24_patch_max=3

versions=()

append_k8s_version() {
prefix=$1
max=$2
for i in $(seq 0 "$max");
do
versions+=("${prefix}${i}")
done
}

append_k8s_version "v1.22." $v22_patch_max
append_k8s_version "v1.23." $v23_patch_max
append_k8s_version "v1.24." $v24_patch_max

#versions=("v1.22.12" "v1.23.9" "v1.24.3")

arches=("amd64" "arm64")
apps=("kubeadm" "kubelet" "kubectl")
json="{}"
for app in "${apps[@]}";
do
for arch in "${arches[@]}"
do
echo "${app}@${arch}"
for ver in "${versions[@]}"
do
url="https://storage.googleapis.com/kubernetes-release/release/${ver}/bin/linux/${arch}/${app}.sha256"
hash=$(wget --quiet -O - "$url")
echo "\"${ver}\": \"${hash}\","
json=$(echo "$json" | jq ".${app}.${arch} += {\"${ver}\":\"${hash}\"}")
done
done
done

file="kubernetes-hashes.json"
echo "$json" | jq --indent 4 > "${file}" && echo -e "\n\nThe hash info have saved to file ${file}.\n\n"

0 comments on commit ca94e5d

Please sign in to comment.