From 41dce8c32ff53edbe394c284e39c985ba8bf7c8a Mon Sep 17 00:00:00 2001 From: kfox1111 Date: Thu, 8 Aug 2024 21:35:22 -0700 Subject: [PATCH] Add oci registry style chart support to infrastructure (#405) Signed-off-by: Kevin Fox Co-authored-by: Faisal Memon --- .github/scripts/parse-versions.sh | 5 +++++ .github/scripts/update-versions.sh | 18 ++++++++++++++++++ .github/tests/oci-charts.json | 7 +++++++ 3 files changed, 30 insertions(+) create mode 100644 .github/tests/oci-charts.json diff --git a/.github/scripts/parse-versions.sh b/.github/scripts/parse-versions.sh index eca9881..60253a5 100644 --- a/.github/scripts/parse-versions.sh +++ b/.github/scripts/parse-versions.sh @@ -7,3 +7,8 @@ REPOS=$(jq -r '.[] | "export " + ("HELM_REPO_" + .name | ascii_upcase | gsub("-" VERSIONS=$(jq -r '.[] | "export " + ("VERSION_" + .name | ascii_upcase | gsub("-";"_")) + "=" + .version' "${TESTS_PATH}/charts.json") eval "$REPOS" eval "$VERSIONS" + +REGISTRIES=$(jq -r '.[] | "export " + ("HELM_REGISTRY_" + .name | ascii_upcase | gsub("-";"_")) + "=oci://" + .registry' "${TESTS_PATH}/oci-charts.json") +VERSIONS=$(jq -r '.[] | "export " + ("VERSION_" + .name | ascii_upcase | gsub("-";"_")) + "=" + .version' "${TESTS_PATH}/oci-charts.json") +eval "$REGISTRIES" +eval "$VERSIONS" diff --git a/.github/scripts/update-versions.sh b/.github/scripts/update-versions.sh index 2be760e..2689e9c 100755 --- a/.github/scripts/update-versions.sh +++ b/.github/scripts/update-versions.sh @@ -22,3 +22,21 @@ jq -r ".[].name" "${CHARTJSON}" | while read -r CHART; do mv /tmp/$$ "${CHARTJSON}" fi done + +CHARTJSON="${SCRIPTPATH}/../tests/oci-charts.json" + +jq -r ".[].name" "${CHARTJSON}" | while read -r NAME; do + ENTRYQUERY='.[] | select(.name == "'$NAME'")' + REGISTRY="$(jq -r "$ENTRYQUERY | .registry" "${CHARTJSON}")" + VERSION="$(jq -r "$ENTRYQUERY | .version" "${CHARTJSON}")" + echo Processing: "${NAME}" + echo " chart: ${REGISTRY}" + echo " current version: ${VERSION}" + LATEST_VERSION=$(crane ls "$REGISTRY" | grep 'v[0-9]*\.[0-9]*\.[0-9]\.*$' | sort -V -r | head -n 1) + echo " latest version: ${LATEST_VERSION}" + if [ "x${VERSION}" != "x${LATEST_VERSION}" ]; then + echo " New version found!" + jq "(${ENTRYQUERY}).version |= \"${LATEST_VERSION}\"" "${CHARTJSON}" > /tmp/$$ + mv /tmp/$$ "${CHARTJSON}" + fi +done diff --git a/.github/tests/oci-charts.json b/.github/tests/oci-charts.json new file mode 100644 index 0000000..78672c4 --- /dev/null +++ b/.github/tests/oci-charts.json @@ -0,0 +1,7 @@ +[ + { + "name": "envoy-gateway", + "registry": "docker.io/envoyproxy/gateway-helm", + "version": "v1.1.0" + } +]