devzone 0.36.7 → 0.38.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.
Files changed (44) hide show
  1. package/.devcontainer/.dockerignore +1 -1
  2. package/.devcontainer/argocd/application.sh +69 -0
  3. package/.devcontainer/argocd/apps.sh +262 -0
  4. package/.devcontainer/argocd/argocd.sh +52 -8
  5. package/.devcontainer/argocd/catalogue-argocd.sh +114 -0
  6. package/.devcontainer/argocd/conf.sh +141 -0
  7. package/.devcontainer/argocd/gitops.sh +214 -0
  8. package/.devcontainer/argocd/services.sh +138 -0
  9. package/.devcontainer/catalogue/app.sh +58 -17
  10. package/.devcontainer/catalogue/mysql/installer.sh +31 -0
  11. package/.devcontainer/catalogue/mysql/mysql.sh +12 -0
  12. package/.devcontainer/devzone +2 -1
  13. package/.devcontainer/password.sh +8 -0
  14. package/README.md +2 -2
  15. package/charts/devzone-argocd/Chart.lock +6 -0
  16. package/charts/devzone-argocd/Chart.yaml +13 -0
  17. package/charts/devzone-argocd/values.yaml +28 -0
  18. package/charts/devzone-mysql/Chart.yaml +6 -0
  19. package/charts/devzone-mysql/templates/service.yaml +15 -0
  20. package/charts/devzone-mysql/templates/statefulset.yaml +55 -0
  21. package/charts/devzone-mysql/values.yaml +19 -0
  22. package/charts/devzone-postgres/Chart.yaml +6 -0
  23. package/charts/devzone-postgres/templates/service.yaml +15 -0
  24. package/charts/devzone-postgres/templates/statefulset.yaml +56 -0
  25. package/charts/devzone-postgres/values.yaml +11 -0
  26. package/manage/devzone +4 -1
  27. package/manage/scripts/argocd-services-svc.sh +110 -0
  28. package/manage/scripts/argocd-services.sh +179 -0
  29. package/manage/scripts/argocd-workspace.sh +221 -0
  30. package/manage/scripts/ci-dns.sh +10 -10
  31. package/manage/scripts/desinstaller.sh +137 -135
  32. package/manage/scripts/docker.sh +26 -22
  33. package/manage/scripts/lancer.sh +103 -103
  34. package/manage/scripts/migrer-retour.sh +37 -34
  35. package/manage/scripts/migrer.sh +154 -138
  36. package/manage/scripts/ports-workspace.sh +94 -82
  37. package/manage/scripts/poste.sh +48 -49
  38. package/manage/scripts/services-workspace.sh +22 -5
  39. package/manage/scripts/versions.sh +88 -88
  40. package/manage/scripts/workspace-aliases.sh +47 -0
  41. package/manage/scripts/workspace-wait.sh +27 -24
  42. package/manage/workspace.sh +134 -105
  43. package/package.json +1 -1
  44. package/.devcontainer/argocd/values.yaml +0 -21
@@ -1,46 +1,51 @@
1
1
  #!/usr/bin/env bash
2
- # Migration du poste Docker vers le workspace Kubernetes, et retour arrière (#403).
3
- # Sourcé par manage/workspace.sh : utilise POD, NAMESPACE, DOSSIER_PROJETS,
4
- # drapeau_kubectl, copier_vers et copier_depuis. Rien n'est jamais supprimé, sauf
5
- # par nettoyer-docker, après confirmation. Lancé depuis le dossier devzone du poste.
6
-
7
- # Home de vscode dans le pod et image des copies de volumes Docker.
8
- HOME_POD="/home/vscode"
9
- IMAGE_COPIE="${DEVZONE_IMAGE_COPIE:-busybox:1.36}"
10
- # Volumes Docker du poste : devzone-<x>, ou $DEVZONE_VOLUMES-<x> (tests fonctionnels).
11
- VOLUMES_DOCKER=(gh git claude opencode-config opencode-data agent config m2 gradle pnpm)
12
- # Mesure d'un dossier ($1) : « nombre de fichiers octets ».
13
- MESURE='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"'
14
-
15
- # kubectl du poste, contexte devzone s'il existe, namespace du workspace.
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 drapeau
18
- drapeau="$(drapeau_kubectl)"
18
+ local flag
19
+ flag="$(kubectl_flag)"
19
20
  # shellcheck disable=SC2086
20
- kubectl $drapeau --namespace "$NAMESPACE" "$@"
21
+ kubectl $flag --namespace "$NAMESPACE" "$@"
21
22
  }
22
23
 
23
- # Erreur claire sur stderr (le code 1 est rendu par l'appelant).
24
- echec() {
24
+ # Clear error on stderr (exit code 1 returned by caller).
25
+ fail() {
25
26
  echo "✖ $*" >&2
26
27
  }
27
28
 
28
- # Lit l'unique option acceptée ($1) des arguments suivants ($3…) : affiche 1 si
29
- # présente, 0 sinon ; toute autre option : erreur avec l'usage ($2), code 1.
30
- lire_option() {
31
- local option="$1" usage="$2" a trouve=0
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" = "$option" ]; then trouve=1; continue; fi
35
- echec "option inconnue : $a (devzone workspace $usage)"
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 "$trouve"
43
+ echo "$found"
39
44
  }
40
45
 
41
- # Chemin du volume etat (relatif au home de vscode) d'un volume Docker devzone-<x> ;
42
- # vide si le chart n'en monte aucun (persistence.state.paths).
43
- chemin_etat() {
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
- # Nom du volume Docker de <x>.
58
- volume_docker() {
62
+ # Docker volume name for <x>.
63
+ docker_volume() {
59
64
  printf '%s-%s' "${DEVZONE_VOLUMES:-devzone}" "$1"
60
65
  }
61
66
 
62
- # Demande [o/N] ($1 : question, $2 : 1 si --oui). Sans terminal et sans --oui : refus.
63
- confirmer() {
64
- local rep=""
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 "✖ pas de terminal : confirmation impossible, relance avec --oui" >&2
72
+ echo "✖ no terminal: cannot confirm, run again with --yes" >&2
68
73
  return 1
69
74
  fi
70
- read -r -p "$1 [o/N] " rep || true
71
- case "$rep" in o | O | oui | OUI | Oui) return 0 ;; esac
72
- echo "✖ annulé, rien n'a été modifié" >&2
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
- # Compare le dossier du poste ($1) à celui du pod ($2) : mêmes fichiers, même taille.
77
- verifier_copie() {
78
- local poste pod
79
- poste="$(sh -c "$MESURE" _ "$1")"
80
- pod="$(kc exec "$POD" -c workspace -- sh -c "$MESURE" _ "$2")" || pod="illisible"
81
- if [ "$poste" != "$pod" ]; then
82
- echec "copie différente pour $2 : poste « $poste », pod « $pod » (fichiers octets)"
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 : ${poste% *} fichier(s), ${poste#* } octet(s)"
90
+ echo " ✔ $2: ${local_state% *} file(s), ${local_state#* } byte(s)"
86
91
  }
87
92
 
88
- # Étape 1 : cluster joignable, pod démarré, place suffisante pour les projets.
89
- etape_verifs() {
90
- local phase besoin libre
91
- echo "▶ [1/5] vérifications : cluster, workspace, espace"
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
- echec "cluster injoignable : vérifie le contexte kubectl (kubectl config get-contexts)"
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 && docker info >/dev/null 2>&1 || {
97
- echec "Docker ne répond pas : il faut lire les volumes devzone-* du poste"
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" ] || { echec "workspace non démarré (pod $POD : ${phase:-absent}) : devzone workspace demarrer"; return 1; }
102
- besoin=0
103
- [ -d workspace ] && besoin="$(du -sk workspace | cut -f1)"
104
- libre="$(kc exec "$POD" -c workspace -- df -Pk "$DOSSIER_PROJETS" | awk 'NR==2{print $4}')" || libre=0
105
- if [ "${libre:-0}" -lt "$besoin" ]; then
106
- echec "espace insuffisant sur $DOSSIER_PROJETS : ${libre:-0} Ko libres, $besoin Ko de projets"
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 joignable, pod $POD prêt, $libre Ko libres pour $besoin Ko de projets"
114
+ echo " ✔ cluster reachable, pod $POD ready, $free KB free for $needed KB of projects"
110
115
  }
111
116
 
112
- # Étape 2 : chaque projet de ./workspace copié dans le pod, puis vérifié.
113
- etape_projets() {
114
- local d nom
115
- echo "▶ [2/5] projets : ./workspace/<projet> vers $DOSSIER_PROJETS (.git compris)"
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
- nom="$(basename "$d")"
119
- echo " … $nom"
120
- (copier_vers "$d") || { echec "copie du projet $nom échouée"; return 1; }
121
- verifier_copie "$d" "$DOSSIER_PROJETS/$nom" || return 1
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
- # Copie le volume Docker <x> ($1) vers $2 du home du pod, par un conteneur en lecture seule.
126
- copier_volume() {
127
- local v cible="$HOME_POD/$2" tmp statut=0
128
- v="$(volume_docker "$1")"
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" "$IMAGE_COPIE" tar cf - -C /src . | tar xf - -C "$tmp"; then
131
- echec "lecture du volume $v échouée"
132
- statut=1
133
- elif ! kc cp "$tmp/." "$POD:$cible" -c workspace; then
134
- echec "copie de $v vers $cible échouée"
135
- statut=1
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
- verifier_copie "$tmp" "$cible" || statut=1
142
+ verify_copy "$tmp" "$target" || status=1
138
143
  fi
139
144
  rm -rf "$tmp"
140
- return "$statut"
141
- }
142
-
143
- # Étape 3 : identités et caches, volumes Docker vers les chemins du volume etat.
144
- etape_identites() {
145
- local x chemin v
146
- echo "▶ [3/5] identités et caches : volumes Docker vers le volume etat"
147
- for x in "${VOLUMES_DOCKER[@]}"; do
148
- chemin="$(chemin_etat "$x")"
149
- v="$(volume_docker "$x")"
150
- if [ -z "$chemin" ]; then
151
- echo " – $v : aucun chemin dans le volume etat du chart, ignoré"
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 : absent, ignoré"
158
+ echo " – $v: missing, ignored"
154
159
  else
155
- echo " … $v → $HOME_POD/$chemin"
156
- copier_volume "$x" "$chemin" || return 1
160
+ echo " … $v → $POD_HOME/$path"
161
+ copy_volume "$x" "$path" || return 1
157
162
  fi
158
163
  done
159
164
  }
160
165
 
161
- # Étape 4 : .devzone.modules et .devzone.paquets du poste copiés dans le pod.
162
- etape_etat() {
166
+ # Step 4: workstation .devzone.modules and .devzone.paquets copied to the pod.
167
+ step_state() {
163
168
  local f
164
- echo "▶ [4/5] état : .devzone.modules et .devzone.paquets vers $DOSSIER_PROJETS"
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 : absent du poste, ignoré"
172
+ echo " – $f: missing on workstation, skipped"
168
173
  continue
169
174
  fi
170
- kc cp "$PWD/$f" "$POD:$DOSSIER_PROJETS/$f" -c workspace \
171
- && kc exec "$POD" -c workspace -- test -f "$DOSSIER_PROJETS/$f" || { echec "copie de $f échouée ou absente du pod"; return 1; }
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
- # Note workspace=$1 dans .devzone.modules du poste (ligne remplacée, le reste intact).
177
- noter_workspace() {
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
- # Étape 5 : bascule, workspace=kubernetes noté sur le poste ; rien n'est supprimé.
187
- etape_bascule() {
188
- echo "▶ [5/5] bascule : workspace=kubernetes dans .devzone.modules"
189
- noter_workspace kubernetes || { echec "écriture de .devzone.modules impossible"; return 1; }
190
- echo " ✔ fait ; le poste Docker et ses volumes sont intacts (retour : devzone workspace revenir)"
191
- }
192
-
193
- # devzone workspace migrer [--oui] : les cinq étapes, arrêt à la première erreur.
194
- migrer() {
195
- local oui
196
- oui="$(lire_option --oui "migrer [--oui]" "$@")" || return 1
197
- confirmer "Migrer ce poste Docker vers le workspace Kubernetes (copie, rien n'est supprimé) ?" "$oui" || return 1
198
- etape_verifs || return 1
199
- etape_projets || return 1
200
- etape_identites || return 1
201
- etape_etat || return 1
202
- etape_bascule || return 1
203
- echo "✔ migration terminée"
204
- }
205
-
206
- # devzone workspace nettoyer-docker [--oui] : supprime les volumes Docker devzone-*, après confirmation.
207
- nettoyer_docker() {
208
- local oui x v presents=()
209
- oui="$(lire_option --oui "nettoyer-docker [--oui]" "$@")" || return 1
210
- for x in "${VOLUMES_DOCKER[@]}"; do
211
- v="$(volume_docker "$x")"
212
- ! docker volume inspect "$v" >/dev/null 2>&1 || presents+=("$v")
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 [ "${#presents[@]}" -eq 0 ]; then
215
- echo "Aucun volume Docker devzone à supprimer."
222
+ if [ "${#present[@]}" -eq 0 ]; then
223
+ echo "No devzone Docker volume to remove."
216
224
  return 0
217
225
  fi
218
- echo "Volumes Docker à supprimer (irréversible, « revenir » ne les retrouvera plus) :"
219
- printf ' %s\n' "${presents[@]}"
220
- confirmer "Supprimer ces ${#presents[@]} volume(s) ?" "$oui" || return 1
221
- for v in "${presents[@]}"; do
222
- docker volume rm "$v" >/dev/null || { echec "suppression de $v échouée"; return 1; }
223
- echo " ✔ $v supprimé"
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 "$@"; }