fix(platform): stamp the no-delete label on bootstrap cozystack-version

The bootstrap path that creates cozystack-version when the ConfigMap is
absent applied it without the platform.cozystack.io/no-delete label,
leaving it unguarded by the cozystack-no-delete-guardrail
ValidatingAdmissionPolicy. Route it through the shared helper so the
bootstrap ConfigMap carries the label like every migration-driven stamp.

Assisted-By: Claude <noreply@anthropic.com>
Signed-off-by: Aleksei Sviridkin <f@lex.la>
This commit is contained in:
Aleksei Sviridkin committed 2026-06-24 15:32:05 +03:00
1 parent b199b5e438
commit 3aabb0cb7c
1 file changed
+6 -3
@@ -1,6 +1,9 @@
#!/bin/sh
set -euo pipefail
# shellcheck source=migrations/lib/cozystack-version.sh
. /migrations/lib/cozystack-version.sh
NAMESPACE="${NAMESPACE:-cozy-system}"
CURRENT_VERSION="${CURRENT_VERSION:-0}"
TARGET_VERSION="${TARGET_VERSION:-0}"
@@ -10,9 +13,9 @@ echo "Starting migrations from version $CURRENT_VERSION to $TARGET_VERSION"
# Check if ConfigMap exists
if ! kubectl get configmap --namespace "$NAMESPACE" cozystack-version >/dev/null 2>&1; then
echo "ConfigMap cozystack-version does not exist, creating it with version $TARGET_VERSION"
kubectl create configmap --namespace "$NAMESPACE" cozystack-version \
--from-literal=version="$TARGET_VERSION" \
--dry-run=client --output yaml | kubectl apply --filename -
# Stamp via the shared helper so the bootstrap ConfigMap carries the
# platform.cozystack.io/no-delete label like every migration-driven stamp.
stamp_cozystack_version "$TARGET_VERSION"
echo "ConfigMap created with version $TARGET_VERSION"
exit 0
fi