Skip to content

Commit dfa8cb0

Browse files
committed
Download OCI release vector for resolving deployment base image version.
1 parent 146fbcb commit dfa8cb0

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

env.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
2+
set -eo pipefail
33
set -e
44

55
echo "Obtaining release vector variables..."
@@ -8,8 +8,21 @@ yq_shell() {
88
docker run --rm -i -v ${PWD}:/workdir mikefarah/yq:3 /bin/sh -c "$@"
99
}
1010

11+
download_oci_release_vector() {
12+
local image="$1"
13+
local tag="$2"
14+
15+
local token=$(curl -s "https://ghcr.io/token?scope=repository:$IMAGE:pull&service=ghcr.io" | jq -r .token)
16+
17+
local manifest=$(curl -s -L -H "Accept: application/vnd.oci.image.manifest.v1+json" -H "Authorization: Bearer $token" https://ghcr.io/v2/$image/manifests/$tag)
18+
local digst=$(echo "$manifest" | jq -r '.layers[] | select(.mediaType == "application/vnd.metal-stack.release-vector.v1.tar+gzip") | .digest')
19+
20+
RELEASE_YAML="$(curl -s -L -H "Authorization: Bearer $token" "https://ghcr.io/v2/$image/blobs/$digst" | tar xzO release.yaml)"
21+
}
22+
1123
METAL_STACK_RELEASE_VERSION=$(yq_shell "yq r inventories/group_vars/all/release_vector.yaml 'metal_stack_release_version'")
12-
RELEASE_YAML=$(curl -s https://raw.githubusercontent.com/metal-stack/releases/${METAL_STACK_RELEASE_VERSION}/release.yaml)
24+
download_oci_release_vector metal-stack/releases $METAL_STACK_RELEASE_VERSION
25+
1326
METALCTL_IMAGE_TAG=$(yq_shell "echo \"${RELEASE_YAML}\" | yq r - docker-images.metal-stack.control-plane.metalctl.tag")
1427
DEPLOYMENT_BASE_IMAGE_TAG=$(yq_shell "echo \"${RELEASE_YAML}\" | yq r - docker-images.metal-stack.generic.deployment-base.tag")
1528

0 commit comments

Comments
 (0)