File tree Expand file tree Collapse file tree
packages/core/platform/images/migrations/migrations Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1414# the next chart-driven apply sees no diff.
1515#
1616# 3-way-merge note: this apply records the no-delete label in the kubectl
17- # last-applied-configuration annotation under the default field manager.
18- # Any future migration that re-stamps cozystack-version via the same field
19- # manager MUST include the label inline (matching the chart template at
20- # templates/cozystack-version.yaml) — a label-less apply by the same field
21- # manager would strip it.
17+ # last-applied-configuration annotation under the default field manager. A
18+ # label-less apply by the same field manager would strip it, so the manifest
19+ # is rendered by the shared helper (lib/cozystack-version.sh) that every
20+ # migration sources rather than a hand-copied heredoc.
2221
2322set -euo pipefail
2423
24+ # shellcheck source=lib/cozystack-version.sh
25+ . " $( dirname " $0 " ) /lib/cozystack-version.sh"
26+
2527NAMESPACE=" ${NAMESPACE:- cozy-system} "
2628DRY_RUN=" ${MIGRATION_DRY_RUN:- 0} "
2729
28- MANIFEST=$( cat << EOF
29- apiVersion: v1
30- kind: ConfigMap
31- metadata:
32- name: cozystack-version
33- namespace: ${NAMESPACE}
34- labels:
35- platform.cozystack.io/no-delete: "true"
36- data:
37- version: "43"
38- EOF
39- )
30+ MANIFEST=$( render_cozystack_version_manifest 43)
4031
4132if [ " $DRY_RUN " = " 1" ]; then
4233 echo " [dry-run] would apply:"
Original file line number Diff line number Diff line change 1212
1313set -euo pipefail
1414
15+ # shellcheck source=lib/cozystack-version.sh
16+ . " $( dirname " $0 " ) /lib/cozystack-version.sh"
17+
1518# Iterate every namespace that has a Cluster named "seaweedfs-db".
1619for ns in $( kubectl get cluster.postgresql.cnpg.io -A \
1720 -o jsonpath=' {range .items[?(@.metadata.name=="seaweedfs-db")]}{.metadata.namespace}{"\n"}{end}' ) ; do
@@ -27,21 +30,6 @@ for ns in $(kubectl get cluster.postgresql.cnpg.io -A \
2730 fi
2831done
2932
30- # Stamp version.
31- # Mirror migration 42's labeled manifest. A label-less apply by the same field
32- # manager (kubectl create | kubectl apply) would strip the
33- # platform.cozystack.io/no-delete label migration 42 added, dropping
34- # cozystack-version out of the cozystack-no-delete-guardrail
35- # ValidatingAdmissionPolicy. templates/cozystack-version.yaml only re-renders the
36- # labeled ConfigMap on first install, so the label must be carried inline here.
37- kubectl apply --filename - << EOF
38- apiVersion: v1
39- kind: ConfigMap
40- metadata:
41- name: cozystack-version
42- namespace: cozy-system
43- labels:
44- platform.cozystack.io/no-delete: "true"
45- data:
46- version: "44"
47- EOF
33+ # Stamp version. The labeled manifest lives in the shared helper so it cannot
34+ # drift back to a label-less apply that strips platform.cozystack.io/no-delete.
35+ stamp_cozystack_version 44
Original file line number Diff line number Diff line change 1010
1111set -euo pipefail
1212
13+ # shellcheck source=lib/cozystack-version.sh
14+ . " $( dirname " $0 " ) /lib/cozystack-version.sh"
15+
1316if kubectl get deployment flux-tenants -n cozy-fluxcd > /dev/null 2>&1 ; then
1417 # No early-close (head) in the pipe: under pipefail a large name list would
1518 # SIGPIPE kubectl and abort the migration.
@@ -23,21 +26,6 @@ if kubectl get deployment flux-tenants -n cozy-fluxcd >/dev/null 2>&1; then
2326 fi
2427fi
2528
26- # Stamp version.
27- # Mirror migration 43's labeled manifest. A label-less apply by the same field
28- # manager would strip the platform.cozystack.io/no-delete label, dropping
29- # cozystack-version out of the cozystack-no-delete-guardrail
30- # ValidatingAdmissionPolicy. templates/cozystack-version.yaml only re-renders
31- # the labeled ConfigMap on first install, so the label must be carried inline
32- # here.
33- kubectl apply --filename - << EOF
34- apiVersion: v1
35- kind: ConfigMap
36- metadata:
37- name: cozystack-version
38- namespace: cozy-system
39- labels:
40- platform.cozystack.io/no-delete: "true"
41- data:
42- version: "45"
43- EOF
29+ # Stamp version. The labeled manifest lives in the shared helper so it cannot
30+ # drift back to a label-less apply that strips platform.cozystack.io/no-delete.
31+ stamp_cozystack_version 45
You can’t perform that action at this time.
0 commit comments