devzone 0.37.0 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.devcontainer/.dockerignore +1 -1
- package/.devcontainer/argocd/argocd.sh +6 -7
- package/.devcontainer/argocd/catalogue-argocd.sh +114 -0
- package/.devcontainer/argocd/gitops.sh +18 -0
- package/.devcontainer/argocd/services.sh +138 -0
- package/.devcontainer/catalogue/app.sh +58 -17
- package/.devcontainer/catalogue/mysql/installer.sh +31 -0
- package/.devcontainer/catalogue/mysql/mysql.sh +12 -0
- package/.devcontainer/devzone +17 -2
- package/.devcontainer/etat-json.sh +5 -1
- package/.devcontainer/password.sh +8 -0
- package/README.md +7 -1
- package/charts/devzone-argocd/Chart.lock +6 -0
- package/charts/devzone-argocd/Chart.yaml +13 -0
- package/charts/devzone-argocd/values.yaml +28 -0
- package/charts/devzone-mysql/Chart.yaml +6 -0
- package/charts/devzone-mysql/templates/service.yaml +15 -0
- package/charts/devzone-mysql/templates/statefulset.yaml +55 -0
- package/charts/devzone-mysql/values.yaml +19 -0
- package/manage/devzone +83 -4
- package/manage/scripts/argocd-services-svc.sh +110 -0
- package/manage/scripts/argocd-services.sh +21 -85
- package/manage/scripts/argocd-workspace.sh +8 -6
- package/manage/scripts/ci-dns.sh +10 -10
- package/manage/scripts/desinstaller.sh +150 -136
- package/manage/scripts/docker.sh +26 -22
- package/manage/scripts/lancer.sh +103 -103
- package/manage/scripts/migrer-retour.sh +37 -34
- package/manage/scripts/migrer.sh +154 -138
- package/manage/scripts/ports-workspace.sh +87 -82
- package/manage/scripts/poste.sh +48 -49
- package/manage/scripts/services-workspace.sh +15 -10
- package/manage/scripts/versions.sh +88 -88
- package/manage/scripts/workspace-aliases.sh +47 -0
- package/manage/scripts/workspace-wait.sh +26 -23
- package/manage/workspace.sh +124 -111
- package/package.json +1 -1
- package/.devcontainer/argocd/values.yaml +0 -25
package/manage/scripts/migrer.sh
CHANGED
|
@@ -1,46 +1,51 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Migration
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
6
|
-
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
#
|
|
11
|
-
|
|
12
|
-
#
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
2
|
+
# Migration from Docker workstation to Kubernetes workspace, and rollback (#403).
|
|
3
|
+
# Sourced by manage/workspace.sh: uses POD, NAMESPACE, PROJECTS_DIR,
|
|
4
|
+
# kubectl_flag, copy_to and copy_from. Nothing is ever deleted except by
|
|
5
|
+
# clean-docker, after confirmation. Run from the devzone workstation folder.
|
|
6
|
+
|
|
7
|
+
# vscode home in the pod and image used to copy Docker volumes.
|
|
8
|
+
POD_HOME="/home/vscode"
|
|
9
|
+
COPY_IMAGE="${DEVZONE_IMAGE_COPIE:-busybox:1.36}"
|
|
10
|
+
# Docker workstation volumes: devzone-<x>, or $DEVZONE_VOLUMES-<x> (functional tests).
|
|
11
|
+
DOCKER_VOLUMES=(gh git claude opencode-config opencode-data agent config m2 gradle pnpm)
|
|
12
|
+
# Folder size measurement ($1): "file count bytes".
|
|
13
|
+
# shellcheck disable=SC2016
|
|
14
|
+
MEASURE='n=$(find "$1" -type f | wc -l | tr -d " "); o=$(find "$1" -type f -exec wc -c {} + 2>/dev/null | awk '\''$2!="total"{s+=$1} END{print s+0}'\''); echo "$n $o"'
|
|
15
|
+
|
|
16
|
+
# Workstation kubectl, devzone context if it exists, workspace namespace.
|
|
16
17
|
kc() {
|
|
17
|
-
local
|
|
18
|
-
|
|
18
|
+
local flag
|
|
19
|
+
flag="$(kubectl_flag)"
|
|
19
20
|
# shellcheck disable=SC2086
|
|
20
|
-
kubectl $
|
|
21
|
+
kubectl $flag --namespace "$NAMESPACE" "$@"
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
#
|
|
24
|
-
|
|
24
|
+
# Clear error on stderr (exit code 1 returned by caller).
|
|
25
|
+
fail() {
|
|
25
26
|
echo "✖ $*" >&2
|
|
26
27
|
}
|
|
27
28
|
|
|
28
|
-
#
|
|
29
|
-
#
|
|
30
|
-
|
|
31
|
-
local
|
|
29
|
+
# Reads the single accepted flag ($1) from following args ($3…): prints 1 if
|
|
30
|
+
# present, 0 otherwise; any other flag: error with usage ($2), exit code 1.
|
|
31
|
+
read_flag() {
|
|
32
|
+
local flag="$1" usage="$2" a found=0 legacy=""
|
|
32
33
|
shift 2
|
|
34
|
+
case "$flag" in
|
|
35
|
+
--yes) legacy="--oui" ;;
|
|
36
|
+
--bring-back) legacy="--rapatrier" ;;
|
|
37
|
+
esac
|
|
33
38
|
for a in "$@"; do
|
|
34
|
-
if [ "$a" = "$
|
|
35
|
-
|
|
39
|
+
if [ "$a" = "$flag" ] || { [ -n "$legacy" ] && [ "$a" = "$legacy" ]; }; then found=1; continue; fi
|
|
40
|
+
fail "unknown option: $a (devzone workspace $usage)"
|
|
36
41
|
return 1
|
|
37
42
|
done
|
|
38
|
-
echo "$
|
|
43
|
+
echo "$found"
|
|
39
44
|
}
|
|
40
45
|
|
|
41
|
-
#
|
|
42
|
-
#
|
|
43
|
-
|
|
46
|
+
# State volume path (relative to vscode home) for a devzone-<x> Docker volume;
|
|
47
|
+
# empty if the chart mounts none (persistence.state.paths).
|
|
48
|
+
state_path() {
|
|
44
49
|
case "$1" in
|
|
45
50
|
gh) echo .config/gh ;;
|
|
46
51
|
git) echo .config/git ;;
|
|
@@ -54,127 +59,130 @@ chemin_etat() {
|
|
|
54
59
|
esac
|
|
55
60
|
}
|
|
56
61
|
|
|
57
|
-
#
|
|
58
|
-
|
|
62
|
+
# Docker volume name for <x>.
|
|
63
|
+
docker_volume() {
|
|
59
64
|
printf '%s-%s' "${DEVZONE_VOLUMES:-devzone}" "$1"
|
|
60
65
|
}
|
|
61
66
|
|
|
62
|
-
#
|
|
63
|
-
|
|
64
|
-
local
|
|
67
|
+
# Asks [y/N] ($1: question, $2: 1 if --yes). Without terminal and without --yes: refuse.
|
|
68
|
+
confirm() {
|
|
69
|
+
local reply=""
|
|
65
70
|
[ "${2:-0}" = 1 ] && return 0
|
|
66
71
|
if [ ! -t 0 ]; then
|
|
67
|
-
echo "✖
|
|
72
|
+
echo "✖ no terminal: cannot confirm, run again with --yes" >&2
|
|
68
73
|
return 1
|
|
69
74
|
fi
|
|
70
|
-
read -r -p "$1 [
|
|
71
|
-
case "$
|
|
72
|
-
echo "✖
|
|
75
|
+
read -r -p "$1 [y/N] " reply || true
|
|
76
|
+
case "$reply" in y | Y | yes | YES | Yes | o | O | oui | OUI | Oui) return 0 ;; esac
|
|
77
|
+
echo "✖ canceled, nothing changed" >&2
|
|
73
78
|
return 1
|
|
74
79
|
}
|
|
75
80
|
|
|
76
|
-
#
|
|
77
|
-
|
|
78
|
-
local
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
if [ "$
|
|
82
|
-
|
|
81
|
+
# Compares workstation folder ($1) with pod folder ($2): same files, same size.
|
|
82
|
+
verify_copy() {
|
|
83
|
+
local local_state pod_state
|
|
84
|
+
local_state="$(sh -c "$MEASURE" _ "$1")"
|
|
85
|
+
pod_state="$(kc exec "$POD" -c workspace -- sh -c "$MEASURE" _ "$2")" || pod_state="unreadable"
|
|
86
|
+
if [ "$local_state" != "$pod_state" ]; then
|
|
87
|
+
fail "different copy for $2: workstation \"$local_state\", pod \"$pod_state\" (files bytes)"
|
|
83
88
|
return 1
|
|
84
89
|
fi
|
|
85
|
-
echo " ✔ $2
|
|
90
|
+
echo " ✔ $2: ${local_state% *} file(s), ${local_state#* } byte(s)"
|
|
86
91
|
}
|
|
87
92
|
|
|
88
|
-
#
|
|
89
|
-
|
|
90
|
-
local phase
|
|
91
|
-
echo "▶ [1/5]
|
|
93
|
+
# Step 1: cluster reachable, pod started, enough space for projects.
|
|
94
|
+
step_checks() {
|
|
95
|
+
local phase needed free
|
|
96
|
+
echo "▶ [1/5] checks: cluster, workspace, space"
|
|
92
97
|
kc get --raw /readyz >/dev/null 2>&1 || {
|
|
93
|
-
|
|
98
|
+
fail "unreachable cluster: check kubectl context (kubectl config get-contexts)"
|
|
94
99
|
return 1
|
|
95
100
|
}
|
|
96
|
-
command -v docker >/dev/null 2>&1
|
|
97
|
-
|
|
101
|
+
if ! command -v docker >/dev/null 2>&1 || ! docker info >/dev/null 2>&1; then
|
|
102
|
+
fail "Docker does not respond: devzone-* workstation volumes must be readable"
|
|
98
103
|
return 1
|
|
99
|
-
|
|
104
|
+
fi
|
|
100
105
|
phase="$(kc get pod "$POD" -o 'jsonpath={.status.phase}' 2>/dev/null || true)"
|
|
101
|
-
[ "$phase" = "Running" ] || {
|
|
102
|
-
|
|
103
|
-
[ -d workspace ] &&
|
|
104
|
-
|
|
105
|
-
if [ "${
|
|
106
|
-
|
|
106
|
+
[ "$phase" = "Running" ] || { fail "workspace not started (pod $POD: ${phase:-missing}): devzone workspace start"; return 1; }
|
|
107
|
+
needed=0
|
|
108
|
+
[ -d workspace ] && needed="$(du -sk workspace | cut -f1)"
|
|
109
|
+
free="$(kc exec "$POD" -c workspace -- df -Pk "$PROJECTS_DIR" | awk 'NR==2{print $4}')" || free=0
|
|
110
|
+
if [ "${free:-0}" -lt "$needed" ]; then
|
|
111
|
+
fail "not enough space on $PROJECTS_DIR: ${free:-0} KB free, $needed KB of projects"
|
|
107
112
|
return 1
|
|
108
113
|
fi
|
|
109
|
-
echo " ✔ cluster
|
|
114
|
+
echo " ✔ cluster reachable, pod $POD ready, $free KB free for $needed KB of projects"
|
|
110
115
|
}
|
|
111
116
|
|
|
112
|
-
#
|
|
113
|
-
|
|
114
|
-
local d
|
|
115
|
-
echo "▶ [2/5]
|
|
117
|
+
# Step 2: each project in ./workspace copied to the pod, then verified.
|
|
118
|
+
step_projects() {
|
|
119
|
+
local d name
|
|
120
|
+
echo "▶ [2/5] projects: ./workspace/<project> to $PROJECTS_DIR (.git included)"
|
|
116
121
|
for d in workspace/*/; do
|
|
117
122
|
[ -d "$d" ] || continue
|
|
118
|
-
|
|
119
|
-
echo " … $
|
|
120
|
-
(
|
|
121
|
-
|
|
123
|
+
name="$(basename "$d")"
|
|
124
|
+
echo " … $name"
|
|
125
|
+
(copy_to "$d") || { fail "project $name copy failed"; return 1; }
|
|
126
|
+
verify_copy "$d" "$PROJECTS_DIR/$name" || return 1
|
|
122
127
|
done
|
|
123
128
|
}
|
|
124
129
|
|
|
125
|
-
#
|
|
126
|
-
|
|
127
|
-
local v
|
|
128
|
-
v="$(
|
|
130
|
+
# Copies Docker volume <x> ($1) to $2 under pod home, through a read-only container.
|
|
131
|
+
copy_volume() {
|
|
132
|
+
local v target="$POD_HOME/$2" tmp status=0
|
|
133
|
+
v="$(docker_volume "$1")"
|
|
129
134
|
tmp="$(mktemp -d)"
|
|
130
|
-
if ! docker run --rm -v "$v:/src:ro" "$
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
elif ! kc cp "$tmp/." "$POD:$
|
|
134
|
-
|
|
135
|
-
|
|
135
|
+
if ! docker run --rm -v "$v:/src:ro" "$COPY_IMAGE" tar cf - -C /src . | tar xf - -C "$tmp"; then
|
|
136
|
+
fail "volume $v read failed"
|
|
137
|
+
status=1
|
|
138
|
+
elif ! kc cp "$tmp/." "$POD:$target" -c workspace; then
|
|
139
|
+
fail "volume $v copy to $target failed"
|
|
140
|
+
status=1
|
|
136
141
|
else
|
|
137
|
-
|
|
142
|
+
verify_copy "$tmp" "$target" || status=1
|
|
138
143
|
fi
|
|
139
144
|
rm -rf "$tmp"
|
|
140
|
-
return "$
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
#
|
|
144
|
-
|
|
145
|
-
local x
|
|
146
|
-
echo "▶ [3/5]
|
|
147
|
-
for x in "${
|
|
148
|
-
|
|
149
|
-
v="$(
|
|
150
|
-
if [ -z "$
|
|
151
|
-
echo " – $v
|
|
145
|
+
return "$status"
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
# Step 3: identities and caches, Docker volumes to state volume paths.
|
|
149
|
+
step_identities() {
|
|
150
|
+
local x path v
|
|
151
|
+
echo "▶ [3/5] identities and caches: Docker volumes to state volume"
|
|
152
|
+
for x in "${DOCKER_VOLUMES[@]}"; do
|
|
153
|
+
path="$(state_path "$x")"
|
|
154
|
+
v="$(docker_volume "$x")"
|
|
155
|
+
if [ -z "$path" ]; then
|
|
156
|
+
echo " – $v: no path in chart, skipped"
|
|
152
157
|
elif ! docker volume inspect "$v" >/dev/null 2>&1; then
|
|
153
|
-
echo " – $v
|
|
158
|
+
echo " – $v: missing, ignored"
|
|
154
159
|
else
|
|
155
|
-
echo " … $v → $
|
|
156
|
-
|
|
160
|
+
echo " … $v → $POD_HOME/$path"
|
|
161
|
+
copy_volume "$x" "$path" || return 1
|
|
157
162
|
fi
|
|
158
163
|
done
|
|
159
164
|
}
|
|
160
165
|
|
|
161
|
-
#
|
|
162
|
-
|
|
166
|
+
# Step 4: workstation .devzone.modules and .devzone.paquets copied to the pod.
|
|
167
|
+
step_state() {
|
|
163
168
|
local f
|
|
164
|
-
echo "▶ [4/5]
|
|
169
|
+
echo "▶ [4/5] state: .devzone.modules and .devzone.paquets to $PROJECTS_DIR"
|
|
165
170
|
for f in .devzone.modules .devzone.paquets; do
|
|
166
171
|
if [ ! -f "$f" ]; then
|
|
167
|
-
echo " – $f
|
|
172
|
+
echo " – $f: missing on workstation, skipped"
|
|
168
173
|
continue
|
|
169
174
|
fi
|
|
170
|
-
kc cp "$PWD/$f" "$POD:$
|
|
171
|
-
|
|
175
|
+
if ! kc cp "$PWD/$f" "$POD:$PROJECTS_DIR/$f" -c workspace \
|
|
176
|
+
|| ! kc exec "$POD" -c workspace -- test -f "$PROJECTS_DIR/$f"; then
|
|
177
|
+
fail "failed to copy $f or missing from pod"
|
|
178
|
+
return 1
|
|
179
|
+
fi
|
|
172
180
|
echo " ✔ $f"
|
|
173
181
|
done
|
|
174
182
|
}
|
|
175
183
|
|
|
176
|
-
#
|
|
177
|
-
|
|
184
|
+
# Writes workspace=$1 in workstation .devzone.modules (line replaced, rest kept).
|
|
185
|
+
record_workspace() {
|
|
178
186
|
local f=".devzone.modules" tmp
|
|
179
187
|
tmp="$f.tmp.$$"
|
|
180
188
|
{
|
|
@@ -183,43 +191,51 @@ noter_workspace() {
|
|
|
183
191
|
} >"$tmp" && mv "$tmp" "$f"
|
|
184
192
|
}
|
|
185
193
|
|
|
186
|
-
#
|
|
187
|
-
|
|
188
|
-
echo "▶ [5/5]
|
|
189
|
-
|
|
190
|
-
echo " ✔
|
|
191
|
-
}
|
|
192
|
-
|
|
193
|
-
# devzone workspace
|
|
194
|
-
|
|
195
|
-
local
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
echo "✔ migration
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
# devzone workspace
|
|
207
|
-
|
|
208
|
-
local
|
|
209
|
-
|
|
210
|
-
for x in "${
|
|
211
|
-
v="$(
|
|
212
|
-
! docker volume inspect "$v" >/dev/null 2>&1 ||
|
|
194
|
+
# Step 5: switch, workspace=kubernetes recorded on workstation; nothing is deleted.
|
|
195
|
+
step_switch() {
|
|
196
|
+
echo "▶ [5/5] switch: workspace=kubernetes in .devzone.modules"
|
|
197
|
+
record_workspace kubernetes || { fail "cannot write .devzone.modules"; return 1; }
|
|
198
|
+
echo " ✔ done; Docker workstation and its volumes are intact (rollback: devzone workspace revert)"
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
# devzone workspace migrate [--yes]: the five steps, stop at first error.
|
|
202
|
+
migrate_workspace() {
|
|
203
|
+
local yes
|
|
204
|
+
yes="$(read_flag --yes "migrate [--yes]" "$@")" || return 1
|
|
205
|
+
confirm "Migrate this Docker workstation to the Kubernetes workspace (copy, nothing is deleted)?" "$yes" || return 1
|
|
206
|
+
step_checks || return 1
|
|
207
|
+
step_projects || return 1
|
|
208
|
+
step_identities || return 1
|
|
209
|
+
step_state || return 1
|
|
210
|
+
step_switch || return 1
|
|
211
|
+
echo "✔ migration complete"
|
|
212
|
+
}
|
|
213
|
+
|
|
214
|
+
# devzone workspace clean-docker [--yes]: removes devzone-* Docker volumes, after confirmation.
|
|
215
|
+
clean_docker() {
|
|
216
|
+
local yes x v present=()
|
|
217
|
+
yes="$(read_flag --yes "clean-docker [--yes]" "$@")" || return 1
|
|
218
|
+
for x in "${DOCKER_VOLUMES[@]}"; do
|
|
219
|
+
v="$(docker_volume "$x")"
|
|
220
|
+
! docker volume inspect "$v" >/dev/null 2>&1 || present+=("$v")
|
|
213
221
|
done
|
|
214
|
-
if [ "${#
|
|
215
|
-
echo "
|
|
222
|
+
if [ "${#present[@]}" -eq 0 ]; then
|
|
223
|
+
echo "No devzone Docker volume to remove."
|
|
216
224
|
return 0
|
|
217
225
|
fi
|
|
218
|
-
echo "
|
|
219
|
-
printf ' %s\n' "${
|
|
220
|
-
|
|
221
|
-
for v in "${
|
|
222
|
-
docker volume rm "$v" >/dev/null || {
|
|
223
|
-
echo " ✔ $v
|
|
226
|
+
echo "Docker volumes to remove (irreversible, \"revert\" will not find them again):"
|
|
227
|
+
printf ' %s\n' "${present[@]}"
|
|
228
|
+
confirm "Remove these ${#present[@]} volume(s)?" "$yes" || return 1
|
|
229
|
+
for v in "${present[@]}"; do
|
|
230
|
+
docker volume rm "$v" >/dev/null || { fail "failed to remove $v"; return 1; }
|
|
231
|
+
echo " ✔ $v removed"
|
|
224
232
|
done
|
|
225
233
|
}
|
|
234
|
+
|
|
235
|
+
# compatibility aliases, removed with lot 4 (#509)
|
|
236
|
+
lire_option() { read_flag "$@"; }
|
|
237
|
+
confirmer() { confirm "$@"; }
|
|
238
|
+
noter_workspace() { record_workspace "$@"; }
|
|
239
|
+
migrer() { migrate_workspace "$@"; }
|
|
240
|
+
nettoyer_docker() { clean_docker "$@"; }
|
|
241
|
+
echec() { fail "$@"; }
|