Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions env.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#!/usr/bin/env bash

set -eo pipefail
set -e

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

download_oci_release_vector() {
local image="$1"
local tag="$2"

local token=$(curl -s "https://ghcr.io/token?scope=repository:$image:pull&service=ghcr.io" | jq -r .token)

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)
local digest=$(echo "$manifest" | jq -r '.layers[] | select(.mediaType == "application/vnd.metal-stack.release-vector.v1.tar+gzip") | .digest')

RELEASE_YAML="$(curl -s -L -H "Authorization: Bearer $token" "https://ghcr.io/v2/$image/blobs/$digest" | tar xzO release.yaml)"
}

METAL_STACK_RELEASE_VERSION=$(yq_shell "yq r inventories/group_vars/all/release_vector.yaml 'metal_stack_release_version'")
RELEASE_YAML=$(curl -s https://raw.githubusercontent.com/metal-stack/releases/${METAL_STACK_RELEASE_VERSION}/release.yaml)
download_oci_release_vector metal-stack/releases $METAL_STACK_RELEASE_VERSION

METALCTL_IMAGE_TAG=$(yq_shell "echo \"${RELEASE_YAML}\" | yq r - docker-images.metal-stack.control-plane.metalctl.tag")
DEPLOYMENT_BASE_IMAGE_TAG=$(yq_shell "echo \"${RELEASE_YAML}\" | yq r - docker-images.metal-stack.generic.deployment-base.tag")

Expand Down
Loading