|
| 1 | +#!/usr/bin/env bats |
| 2 | +# Upstream releases the Proxmox CSI controller and node plugin together, and |
| 3 | +# its chart renders both from one appVersion. Here they run in two places and |
| 4 | +# are pinned in two packages: the controller in the management cluster |
| 5 | +# (packages/apps/kubernetes, an images/.tag file) and the node plugin in the |
| 6 | +# tenant (packages/system/proxmox-csi, a values override on the vendored |
| 7 | +# chart). Both are pinned by digest because tags in that registry have been |
| 8 | +# re-pushed, and the pin is what takes the version out of the chart's hands: |
| 9 | +# `make update` with a new CHART_VERSION brings new templates and a new |
| 10 | +# appVersion while both pins keep naming the old build, and nothing else |
| 11 | +# notices. |
| 12 | +# |
| 13 | +# This asserts the chart's appVersion and both pins name the same release. |
| 14 | + |
| 15 | +load test_helper |
| 16 | + |
| 17 | +REPO_ROOT="$(cd "$(dirname "${BATS_TEST_FILENAME:-$0}")/.." && pwd)" |
| 18 | + |
| 19 | +@test "the Proxmox CSI controller and node plugin pin the vendored chart's release" { |
| 20 | + chart="$REPO_ROOT/packages/system/proxmox-csi/charts/proxmox-csi-plugin/Chart.yaml" |
| 21 | + values="$REPO_ROOT/packages/system/proxmox-csi/values.yaml" |
| 22 | + tagfile="$REPO_ROOT/packages/apps/kubernetes/images/proxmox-csi-controller.tag" |
| 23 | + |
| 24 | + app_version=$(yq -r '.appVersion' "$chart") |
| 25 | + node_tag=$(yq -r '."proxmox-csi-plugin".node.plugin.image.tag' "$values") |
| 26 | + controller_ref=$(tr -d '[:space:]' < "$tagfile") |
| 27 | + |
| 28 | + [ -n "$app_version" ] && [ "$app_version" != null ] || { |
| 29 | + echo "no appVersion in $chart" >&2 |
| 30 | + return 1 |
| 31 | + } |
| 32 | + |
| 33 | + [ "${node_tag%%@*}" = "$app_version" ] || { |
| 34 | + echo "node plugin tag '$node_tag' is not the chart appVersion $app_version" >&2 |
| 35 | + echo "set proxmox-csi-plugin.node.plugin.image.tag in packages/system/proxmox-csi/values.yaml" >&2 |
| 36 | + return 1 |
| 37 | + } |
| 38 | + |
| 39 | + [ "${controller_ref%%@*}" = "ghcr.io/sergelogvinov/proxmox-csi-controller:$app_version" ] || { |
| 40 | + echo "controller ref '$controller_ref' is not proxmox-csi-controller:$app_version" >&2 |
| 41 | + echo "update packages/apps/kubernetes/images/proxmox-csi-controller.tag" >&2 |
| 42 | + return 1 |
| 43 | + } |
| 44 | +} |
0 commit comments