Skip to content

Commit

Permalink
Refactored code and added method to get supported version from build-…
Browse files Browse the repository at this point in the history
…toolong repo
  • Loading branch information
jhaanvi5 committed Nov 11, 2024
1 parent 902bb84 commit 2bea272
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions generatebundlefile/hack/update_bundles.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,16 +33,14 @@ function get_latest_version() {

# For cluster autoscaler filter tag based on k8s version (1.28,1.29,etc)
if [ "$repo" = "cluster-autoscaler/charts/cluster-autoscaler" ]; then
output=$(echo $json_output | jq -r --arg kv "1.$k8s_version" '
.imageDetails
| map(select(.imageTags | length > 0))
| map(select(.imageTags | map(test($kv)) | any))
| sort_by(.imagePushedAt)
| last
| .imageTags')
kube_version="1.$k8s_version"
# For metrics-server filter tag based on k8s version (1-28,1-29,etc)
elif [ "$repo" = "metrics-server/charts/metrics-server" ]; then
output=$(echo $json_output | jq -r --arg kv "1-$k8s_version" '
kube_version="1-$k8s_version"
fi

if [ -n "${kube_version:-}" ]; then
output=$(echo $json_output | jq -r --arg kv "$kube_version" '
.imageDetails
| map(select(.imageTags | length > 0))
| map(select(.imageTags | map(test($kv)) | any))
Expand Down Expand Up @@ -109,6 +107,18 @@ function update_bundle() {
done
}

# Function to get supported k8s versions for EKS-A
function get_supported_versions() {
local versions
versions=$(curl -s https://raw.githubusercontent.com/aws/eks-anywhere-build-tooling/main/release/SUPPORTED_RELEASE_BRANCHES |
sed 's/1-//' |
sort -V)

# Get latest version and remove tags with helm
local supported_versions=$(printf "%s\n" "${versions[@]}")
echo $supported_versions
}

function main() {
local environment=""
# Parse command line options
Expand Down Expand Up @@ -139,7 +149,7 @@ function main() {
check_requirements

# Generate bundle files for Kubernetes versions 1.27 to 1.31 for given environment
for version in {27..31}; do
for version in $(get_supported_versions); do
update_bundle "$version" "$environment"
done

Expand Down

0 comments on commit 2bea272

Please sign in to comment.