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,74 +1,81 @@
1
1
  #!/usr/bin/env bash
2
- # Applications et services du workspace Kubernetes sur localhost du poste (#401).
3
- # Sourcé par manage/workspace.sh (fonctions ports_*) ; lancé directement avec
4
- # « boucle » ou « tour », il est le veilleur du poste : un seul, verrou mkdir et pid
5
- # dans .devzone.ports-workspace/. Il relaie par kubectl port-forward, sur 127.0.0.1
6
- # seulement, les ports TCP ≥ 1024 en écoute dans le pod, et les services de devzone
7
- # des modules actifs de .devzone.modules. Garde-fou : jamais sous bats sans
2
+ # Applications and services of the Kubernetes workspace on workstation localhost (#401).
3
+ # Sourced by manage/workspace.sh (ports_* functions); run directly with "loop" or
4
+ # "round", it is the workstation watcher: only one, mkdir lock and pid in
5
+ # .devzone.ports-workspace/. It relays with kubectl port-forward, on 127.0.0.1
6
+ # only, TCP ports >= 1024 listening in the pod, and devzone services of active
7
+ # modules in .devzone.modules. Guard: never under bats without
8
8
  # DEVZONE_PORTS_WORKSPACE_REEL=oui.
9
9
 
10
10
  PW_POD="devzone-workspace-0"
11
11
  PW_NS="devzone-workspace"
12
- # Ports internes du pod, jamais relayés : kubedock et buildkit.
13
- PW_INTERNES=" 2475 1234 "
14
- # Port du service pgAdmin : lu dans le service, sans lui rien n'est relayé.
12
+ # Internal pod ports, never relayed: kubedock and buildkit.
13
+ PW_INTERNAL=" 2475 1234 "
14
+ # pgAdmin service port: read from the service, without it nothing is relayed.
15
15
  PW_JSONPATH='jsonpath={.spec.ports[0].port}'
16
16
 
17
- # Dossier d'état du veilleur : verrou, pid, relais, ports signalés, journal.
17
+ # Watcher state folder: lock, pid, relays, reported ports, log.
18
18
  pw_dir() { printf '%s' "${DEVZONE_PORTS_WORKSPACE_DIR:-$PWD/.devzone.ports-workspace}"; }
19
19
 
20
- # Drapeau de contexte kubectl : devzone s'il existe, sinon le contexte courant.
20
+ # kubectl context flag: devzone if it exists, otherwise current context.
21
21
  pw_ctx() {
22
22
  if kubectl config get-contexts -o name 2>/dev/null | grep -qx 'devzone'; then
23
23
  printf -- '--context devzone'
24
24
  fi
25
25
  }
26
26
 
27
- # kubectl du veilleur : contexte devzone s'il existe, puis les arguments reçus.
27
+ # Watcher kubectl: devzone context if it exists, then given arguments.
28
28
  pw_kubectl() {
29
29
  # shellcheck disable=SC2046
30
30
  kubectl $(pw_ctx) "$@"
31
31
  }
32
32
 
33
- # Garde-fou : refuse sous bats sans DEVZONE_PORTS_WORKSPACE_REEL=oui (message si $1 vide).
34
- pw_garde() {
33
+ # Guard: refuse under bats without DEVZONE_PORTS_WORKSPACE_REEL=oui (message if $1 empty).
34
+ pw_guard() {
35
35
  if [ -n "${BATS_TEST_TMPDIR:-}" ] && [ "${DEVZONE_PORTS_WORKSPACE_REEL:-}" != oui ]; then
36
- [ -n "${1:-}" ] || echo "✖ veilleur des ports refusé sous bats (DEVZONE_PORTS_WORKSPACE_REEL=oui requis)" >&2
36
+ [ -n "${1:-}" ] || echo "✖ port watcher refused under bats (DEVZONE_PORTS_WORKSPACE_REEL=oui required)" >&2
37
37
  return 2
38
38
  fi
39
39
  }
40
40
 
41
- # Le processus $1 est-il en vie ?
42
- pw_vivant() { [ -n "${1:-}" ] && kill -0 "$1" 2>/dev/null; }
41
+ # Is process $1 alive?
42
+ pw_alive() { [ -n "${1:-}" ] && kill -0 "$1" 2>/dev/null; }
43
43
 
44
- # Ports TCP ≥ 1024 en écoute dans le pod (ss -ltnH), hors ports internes, un par ligne.
45
- pw_ports_pod() {
44
+ # TCP ports >= 1024 listening in the pod (ss -ltnH), excluding internal ports, one per line.
45
+ pw_pod_ports() {
46
46
  local p
47
47
  pw_kubectl --namespace "$PW_NS" exec "$PW_POD" -c workspace -- ss -ltnH 2>/dev/null |
48
48
  awk '{n=split($4,a,":"); print a[n]}' | sort -un | while read -r p; do
49
49
  case "$p" in '' | *[!0-9]*) continue ;; esac
50
50
  [ "$p" -ge 1024 ] || continue
51
- case "$PW_INTERNES" in *" $p "*) continue ;; esac
51
+ case "$PW_INTERNAL" in *" $p "*) continue ;; esac
52
52
  echo "$p"
53
53
  done
54
54
  }
55
55
 
56
- # Services de devzone à relayer, une ligne « port|namespace|cible » par service des
57
- # modules actifs : postgres (5432) et pgAdmin s'il existe dans le namespace, mysql (3306).
56
+ # devzone services to relay, one "port|namespace|target[|remote port]" line per
57
+ # active module service: postgres (5432) and pgAdmin if present in namespace,
58
+ # mysql (3306), and the Argo CD UI (8443 → 443) when present (#516).
58
59
  pw_services() {
60
+ local port
59
61
  if grep -qxE 'postgres=(on|true|oui)' .devzone.modules 2>/dev/null; then
60
62
  echo "5432|devzone-postgres|svc/postgres"
61
- local port
62
63
  port="$(pw_kubectl --namespace devzone-postgres get svc pgadmin -o "$PW_JSONPATH" 2>/dev/null || true)"
63
64
  case "$port" in '' | *[!0-9]*) ;; *) echo "$port|devzone-postgres|svc/pgadmin" ;; esac
64
65
  fi
65
66
  if grep -qxE 'mysql=(on|true|oui)' .devzone.modules 2>/dev/null; then
66
67
  echo "3306|devzone-mysql|svc/mysql"
67
68
  fi
69
+ # Argo CD UI: https port of svc/argocd-server on 127.0.0.1:8443, unless argocd=off
70
+ if ! grep -qx 'argocd=off' .devzone.modules 2>/dev/null; then
71
+ port="$(pw_kubectl --namespace devzone-argocd get svc argocd-server \
72
+ -o 'jsonpath={.spec.ports[?(@.name=="https")].port}' 2>/dev/null || true)"
73
+ case "$port" in '' | *[!0-9]*) ;; *) echo "${DEVZONE_ARGOCD_PORT:-8443}|devzone-argocd|svc/argocd-server|$port" ;; esac
74
+ fi
68
75
  }
69
76
 
70
- # Le port $1 est-il déjà pris sur le poste ? (lsof, sinon nc -z)
71
- pw_pris() {
77
+ # Is port $1 already in use on the workstation? (lsof, otherwise nc -z)
78
+ pw_taken() {
72
79
  if command -v lsof >/dev/null 2>&1; then
73
80
  lsof -nP -iTCP:"$1" -sTCP:LISTEN >/dev/null 2>&1
74
81
  else
@@ -76,138 +83,143 @@ pw_pris() {
76
83
  fi
77
84
  }
78
85
 
79
- # Lance le relais du port $1 vers la cible $3 du namespace $2, sauf s'il vit déjà ;
80
- # port pris sur le poste : une seule ligne d'avertissement par port.
81
- pw_relayer() {
82
- local port="$1" ns="$2" cible="$3" d pid
86
+ # Starts relay of port $1 to port $4 (default: $1) of target $3 in namespace $2,
87
+ # unless already alive; port taken on workstation: only one warning line per port.
88
+ pw_relay() {
89
+ local port="$1" ns="$2" target="$3" remote="${4:-$1}" d pid
83
90
  d="$(pw_dir)"
84
91
  pid="$(cat "$d/relais/$port" 2>/dev/null || true)"
85
- pw_vivant "$pid" && return 0
86
- if pw_pris "$port"; then
87
- [ -e "$d/pris/$port" ] || { : >"$d/pris/$port"; echo "⚠ port $port déjà pris sur le poste, non relayé"; }
92
+ pw_alive "$pid" && return 0
93
+ if pw_taken "$port"; then
94
+ [ -e "$d/pris/$port" ] || { : >"$d/pris/$port"; echo "⚠ port $port already in use on the workstation, not relayed"; }
88
95
  return 0
89
96
  fi
90
97
  # shellcheck disable=SC2046
91
- kubectl $(pw_ctx) --namespace "$ns" port-forward --address 127.0.0.1 "$cible" "$port:$port" </dev/null >/dev/null 2>&1 &
98
+ kubectl $(pw_ctx) --namespace "$ns" port-forward --address 127.0.0.1 "$target" "$port:$remote" </dev/null >/dev/null 2>&1 &
92
99
  echo $! >"$d/relais/$port"
93
100
  rm -f "$d/pris/$port"
94
- echo "→ port $port relayé sur 127.0.0.1"
101
+ echo "→ port $port relayed on 127.0.0.1"
95
102
  }
96
103
 
97
- # Arrête le relais du port $1 et oublie son avertissement.
98
- pw_retirer() {
104
+ # Stops relay of port $1 and forgets its warning.
105
+ pw_remove() {
99
106
  local d pid
100
107
  d="$(pw_dir)"
101
108
  pid="$(cat "$d/relais/$1" 2>/dev/null || true)"
102
- if pw_vivant "$pid"; then kill "$pid" 2>/dev/null || true; fi
109
+ if pw_alive "$pid"; then kill "$pid" 2>/dev/null || true; fi
103
110
  rm -f "$d/relais/$1" "$d/pris/$1"
104
111
  }
105
112
 
106
- # Un tour du veilleur : relaie les nouveaux ports, retire ceux qui ont disparu.
107
- pw_tour() {
108
- local d voulus="" p ns cible l f
113
+ # One watcher round: relay new ports, remove those that disappeared.
114
+ pw_round() {
115
+ local d wanted="" p ns target remote l f
109
116
  d="$(pw_dir)"
110
117
  mkdir -p "$d/relais" "$d/pris"
111
- while IFS='|' read -r p ns cible; do
118
+ while IFS='|' read -r p ns target remote; do
112
119
  [ -n "$p" ] || continue
113
- voulus="$voulus $p "
114
- pw_relayer "$p" "$ns" "$cible"
120
+ wanted="$wanted $p "
121
+ pw_relay "$p" "$ns" "$target" "${remote:-$p}"
115
122
  done <<<"$(pw_services)"
116
- for p in $(pw_ports_pod); do
117
- case "$voulus" in *" $p "*) continue ;; esac
118
- voulus="$voulus $p "
119
- pw_relayer "$p" "$PW_NS" "pod/$PW_POD"
123
+ for p in $(pw_pod_ports); do
124
+ case "$wanted" in *" $p "*) continue ;; esac
125
+ wanted="$wanted $p "
126
+ pw_relay "$p" "$PW_NS" "pod/$PW_POD"
120
127
  done
121
128
  for f in "$d"/relais/* "$d"/pris/*; do
122
129
  [ -e "$f" ] || continue
123
130
  l="$(basename "$f")"
124
- case "$voulus" in *" $l "*) ;; *) pw_retirer "$l" ;; esac
131
+ case "$wanted" in *" $l "*) ;; *) pw_remove "$l" ;; esac
125
132
  done
126
133
  }
127
134
 
128
- # Retire tous les relais du dossier d'état.
129
- pw_retirer_tout() {
135
+ # Removes all relays from the state folder.
136
+ pw_remove_all() {
130
137
  local f
131
138
  for f in "$(pw_dir)"/relais/*; do
132
- if [ -e "$f" ]; then pw_retirer "$(basename "$f")"; fi
139
+ if [ -e "$f" ]; then pw_remove "$(basename "$f")"; fi
133
140
  done
134
141
  }
135
142
 
136
- # Boucle du veilleur : un tour toutes les 3 s ; à l'arrêt, retire ses relais et son verrou.
137
- pw_boucle() {
143
+ # Watcher loop: one round every 3 s; on stop, removes its relays and lock.
144
+ pw_loop() {
138
145
  local d
139
146
  d="$(pw_dir)"
140
- trap 'pw_retirer_tout; rm -rf "$d/verrou" "$d/pid"; exit 0' TERM INT
147
+ trap 'pw_remove_all; rm -rf "$d/verrou" "$d/pid"; exit 0' TERM INT
141
148
  while :; do
142
- pw_tour || true
149
+ pw_round || true
143
150
  sleep "${DEVZONE_PORTS_WORKSPACE_PAS:-3}" &
144
151
  wait $!
145
152
  done
146
153
  }
147
154
 
148
- # Démarre le veilleur, un seul : verrou mkdir, pid noté ; $1=silence : sans message de garde.
155
+ # Starts the watcher, only one: mkdir lock, pid recorded; $1=silence: no guard message.
149
156
  # shellcheck disable=SC2120
150
- ports_demarrer() {
151
- pw_garde "${1:-}" || return 0
157
+ ports_start() {
158
+ pw_guard "${1:-}" || return 0
152
159
  local d pid
153
160
  d="$(pw_dir)"
154
161
  mkdir -p "$d"
155
162
  pid="$(cat "$d/pid" 2>/dev/null || true)"
156
- if pw_vivant "$pid"; then
157
- echo "Ports du workspace : veilleur déjà lancé (pid $pid)"
163
+ if pw_alive "$pid"; then
164
+ echo "Workspace ports: watcher already running (pid $pid)"
158
165
  return 0
159
166
  fi
160
167
  rm -rf "$d/verrou"
161
168
  mkdir "$d/verrou" 2>/dev/null || return 0
162
- nohup bash "${BASH_SOURCE[0]}" boucle >>"$d/journal.log" 2>&1 &
169
+ nohup bash "${BASH_SOURCE[0]}" loop >>"$d/journal.log" 2>&1 &
163
170
  echo $! >"$d/pid"
164
171
  disown 2>/dev/null || true
165
- echo "Ports du workspace : veilleur lancé, journal $d/journal.log"
172
+ echo "Workspace ports: watcher started, log $d/journal.log"
166
173
  }
167
174
 
168
- # Arrête le veilleur et tous ses port-forward ; sans veilleur, retire les restes.
169
- ports_arreter() {
175
+ # Stops the watcher and all its port-forwards; without watcher, removes leftovers.
176
+ ports_stop() {
170
177
  local d pid
171
178
  d="$(pw_dir)"
172
179
  pid="$(cat "$d/pid" 2>/dev/null || true)"
173
- if pw_vivant "$pid"; then
180
+ if pw_alive "$pid"; then
174
181
  kill "$pid" 2>/dev/null || true
175
- for _ in 1 2 3 4 5 6 7 8 9 10; do pw_vivant "$pid" || break; sleep 0.2; done
182
+ for _ in 1 2 3 4 5 6 7 8 9 10; do pw_alive "$pid" || break; sleep 0.2; done
176
183
  fi
177
- pw_retirer_tout
184
+ pw_remove_all
178
185
  rm -rf "$d/verrou" "$d/pid"
179
186
  }
180
187
 
181
- # Affiche l'état : veilleur, ports relayés, ports pris signalés.
182
- ports_etat() {
188
+ # Shows status: watcher, relayed ports, reported taken ports.
189
+ ports_status() {
183
190
  local d pid f
184
191
  d="$(pw_dir)"
185
192
  pid="$(cat "$d/pid" 2>/dev/null || true)"
186
- if pw_vivant "$pid"; then echo "Veilleur des ports : actif (pid $pid)"; else echo "Veilleur des ports : arrêté"; fi
193
+ if pw_alive "$pid"; then echo "Port watcher: running (pid $pid)"; else echo "Port watcher: stopped"; fi
187
194
  for f in "$d"/relais/*; do
188
- if [ -e "$f" ] && pw_vivant "$(cat "$f")"; then echo " 127.0.0.1:$(basename "$f") relayé"; fi
195
+ if [ -e "$f" ] && pw_alive "$(cat "$f")"; then echo " 127.0.0.1:$(basename "$f") relayed"; fi
189
196
  done
190
197
  for f in "$d"/pris/*; do
191
- if [ -e "$f" ]; then echo " ⚠ port $(basename "$f") déjà pris sur le poste, non relayé"; fi
198
+ if [ -e "$f" ]; then echo " ⚠ port $(basename "$f") already in use on the workstation, not relayed"; fi
192
199
  done
193
200
  return 0
194
201
  }
195
202
 
196
- # Sous-commande « devzone workspace ports [demarrer|arreter|etat] » (défaut : etat).
203
+ # Subcommand "devzone workspace ports [start|stop|status]" (default: status).
197
204
  ports() {
198
- case "${1:-etat}" in
199
- demarrer) ports_demarrer ;;
200
- arreter) ports_arreter ;;
201
- etat) ports_etat ;;
202
- *) echo "✖ devzone workspace ports demarrer|arreter|etat" >&2; return 1 ;;
205
+ case "${1:-status}" in
206
+ start | demarrer) ports_start ;;
207
+ stop | arreter) ports_stop ;;
208
+ status | etat) ports_status ;;
209
+ *) echo "✖ devzone workspace ports start|stop|status" >&2; return 1 ;;
203
210
  esac
204
211
  }
205
212
 
206
- # Lancé directement : la boucle du veilleur, ou un seul tour (tests).
213
+ # compatibility aliases, removed with lot 4 (#509)
214
+ ports_demarrer() { ports_start "$@"; }
215
+ ports_arreter() { ports_stop "$@"; }
216
+ ports_etat() { ports_status "$@"; }
217
+
218
+ # Run directly: watcher loop, or a single round (tests).
207
219
  if [ "${BASH_SOURCE[0]}" = "$0" ]; then
208
- pw_garde quiet || exit 2
220
+ pw_guard quiet || exit 2
209
221
  case "${1:-}" in
210
- boucle) pw_boucle ;;
211
- tour) pw_tour ;;
222
+ loop | boucle) pw_loop ;;
223
+ round | tour) pw_round ;;
212
224
  esac
213
225
  fi
@@ -1,35 +1,35 @@
1
1
  #!/usr/bin/env bash
2
- # Pourquoi : make up|shell|stop|rebuild pilote toujours le conteneur Docker,
3
- # même après « devzone workspace migrer », qui note workspace=kubernetes dans
4
- # .devzone.modules (#472). Ce script lit ce mode : en Kubernetes il passe la
5
- # main à manage/workspace.sh (clone du dépôt) ou à npx devzone@<version>
6
- # workspace (dossier créé par npx devzone) ; en Docker il rend 3 sans rien
7
- # faire, et le Makefile garde alors sa recette d'origine. La cible conseil
8
- # affiche, d'après mise à jour, ce que le poste peut faire ensuite (#472).
9
- # Portable : bash 3.2 (macOS) et Linux.
2
+ # Why: make up|shell|stop|rebuild always drives the Docker container, even
3
+ # after "devzone workspace migrate", which writes workspace=kubernetes in
4
+ # .devzone.modules (#472). This script reads that mode: in Kubernetes it hands
5
+ # off to manage/workspace.sh (repo clone) or npx devzone@<version> workspace
6
+ # (folder created by npx devzone); in Docker it returns 3 and does nothing, so
7
+ # the Makefile keeps its original recipe. The advice target shows, after an
8
+ # update, what the workstation can do next (#472).
9
+ # Portable: bash 3.2 (macOS) and Linux.
10
10
  set -uo pipefail
11
11
 
12
12
  usage() {
13
- echo "usage : bash manage/scripts/poste.sh up|shell|stop|rebuild|conseil <dossier>" >&2
13
+ echo "usage: bash manage/scripts/poste.sh up|shell|stop|rebuild|advice <folder>" >&2
14
14
  }
15
15
 
16
- # Dernière valeur workspace= de <dossier>/.devzone.modules ; absente, vide ou
17
- # autre que kubernetes → docker.
18
- mode_workspace() {
19
- local dossier="$1" valeur
20
- valeur="$(grep '^workspace=' "$dossier/.devzone.modules" 2>/dev/null | tail -1 | cut -d= -f2- || true)"
21
- if [ "$valeur" = "kubernetes" ]; then
16
+ # Last workspace= value in <folder>/.devzone.modules; missing, empty or not
17
+ # kubernetes -> docker.
18
+ workspace_mode() {
19
+ local folder="$1" value
20
+ value="$(grep '^workspace=' "$folder/.devzone.modules" 2>/dev/null | tail -1 | cut -d= -f2- || true)"
21
+ if [ "$value" = "kubernetes" ]; then
22
22
  echo kubernetes
23
23
  else
24
24
  echo docker
25
25
  fi
26
26
  }
27
27
 
28
- # Version du dossier : première ligne « version X.Y.Z » de .devzone.version ;
29
- # illisible ou vide → latest.
30
- version_dossier() {
31
- local dossier="$1" version
32
- version="$(sed -n 's/^version \([^[:space:]]*\)[[:space:]]*$/\1/p' "$dossier/.devzone.version" 2>/dev/null | head -1 || true)"
28
+ # Folder version: first "version X.Y.Z" line in .devzone.version; unreadable or
29
+ # empty -> latest.
30
+ folder_version() {
31
+ local folder="$1" version
32
+ version="$(sed -n 's/^version \([^[:space:]]*\)[[:space:]]*$/\1/p' "$folder/.devzone.version" 2>/dev/null | head -1 || true)"
33
33
  if [ -z "$version" ]; then
34
34
  echo latest
35
35
  else
@@ -37,9 +37,9 @@ version_dossier() {
37
37
  fi
38
38
  }
39
39
 
40
- # Kubernetes joignable : kubectl et helm présents, et kubectl cluster-info
41
- # qui répond en 5 s (--context devzone si ce contexte est déclaré).
42
- kube_pret() {
40
+ # Kubernetes reachable: kubectl and helm present, and kubectl cluster-info
41
+ # responds within 5 s (--context devzone if that context is declared).
42
+ kube_ready() {
43
43
  command -v kubectl >/dev/null 2>&1 || return 1
44
44
  command -v helm >/dev/null 2>&1 || return 1
45
45
  if kubectl config get-contexts -o name 2>/dev/null | grep -qx 'devzone'; then
@@ -49,53 +49,52 @@ kube_pret() {
49
49
  fi
50
50
  }
51
51
 
52
- # Commande workspace du dossier : le script du clone s'il existe, sinon la CLI
53
- # publiée de la version du dossier, exécutée depuis le dossier.
52
+ # Workspace command for the folder: clone script if present, otherwise the
53
+ # published CLI for the folder version, run from the folder.
54
54
  workspace_cmd() {
55
- local dossier="$1" version
55
+ local folder="$1" version
56
56
  shift
57
- if [ -f "$dossier/manage/workspace.sh" ]; then
58
- (cd "$dossier" && bash manage/workspace.sh "$@")
57
+ if [ -f "$folder/manage/workspace.sh" ]; then
58
+ (cd "$folder" && bash manage/workspace.sh "$@")
59
59
  else
60
- version="$(version_dossier "$dossier")"
61
- (cd "$dossier" && npx -y "devzone@$version" workspace "$@")
60
+ version="$(folder_version "$folder")"
61
+ (cd "$folder" && npx -y "devzone@$version" workspace "$@")
62
62
  fi
63
63
  }
64
64
 
65
- cible="${1:-}"
66
- dossier="${2:-}"
67
- case "$cible" in
68
- up | shell | stop | rebuild | conseil) ;;
65
+ target="${1:-}"
66
+ folder="${2:-}"
67
+ case "$target" in
68
+ up | shell | stop | rebuild | advice | conseil) ;;
69
69
  *)
70
70
  usage
71
71
  exit 2
72
72
  ;;
73
73
  esac
74
- if [ -z "$dossier" ]; then
74
+ if [ -z "$folder" ]; then
75
75
  usage
76
76
  exit 2
77
77
  fi
78
78
 
79
- # Conseil d'après mise à jour : toujours code 0, rien à faire en Docker sans
80
- # Kubernetes joignable.
81
- if [ "$cible" = conseil ]; then
82
- if [ "$(mode_workspace "$dossier")" = kubernetes ]; then
83
- echo "Workspace Kubernetes : la nouvelle image est prise au prochain devzone workspace demarrer (ou make up)."
84
- elif kube_pret; then
85
- echo "Kubernetes joignable : devzone workspace migrer passe ce poste dans le cluster (rien n'est supprimé, retour : devzone workspace revenir)."
79
+ # Advice after update: always exit 0, nothing to do in Docker without reachable Kubernetes.
80
+ if [ "$target" = "advice" ] || [ "$target" = "conseil" ]; then
81
+ if [ "$(workspace_mode "$folder")" = kubernetes ]; then
82
+ echo "Kubernetes workspace: the new image is used on the next devzone workspace start (or make up)."
83
+ elif kube_ready; then
84
+ echo "Kubernetes reachable: devzone workspace migrate moves this workstation to the cluster (nothing is deleted, rollback: devzone workspace revert)."
86
85
  fi
87
86
  exit 0
88
87
  fi
89
88
 
90
- # Poste Docker : le Makefile reprend sa recette actuelle (code 3).
91
- [ "$(mode_workspace "$dossier")" = kubernetes ] || exit 3
89
+ # Docker workstation: Makefile resumes its current recipe (exit 3).
90
+ [ "$(workspace_mode "$folder")" = kubernetes ] || exit 3
92
91
 
93
- case "$cible" in
94
- up) workspace_cmd "$dossier" demarrer ;;
95
- shell) workspace_cmd "$dossier" demarrer && workspace_cmd "$dossier" shell ;;
96
- stop) workspace_cmd "$dossier" arreter ;;
92
+ case "$target" in
93
+ up) workspace_cmd "$folder" start ;;
94
+ shell) workspace_cmd "$folder" start && workspace_cmd "$folder" shell ;;
95
+ stop) workspace_cmd "$folder" stop ;;
97
96
  rebuild)
98
- echo "✖ make rebuild : ce poste est en workspace Kubernetes (workspace=kubernetes dans .devzone.modules), rien à reconstruire sur la machine ; retour au poste Docker : devzone workspace revenir" >&2
97
+ echo "✖ make rebuild: this workstation is in Kubernetes workspace mode (workspace=kubernetes in .devzone.modules), nothing to rebuild on the machine; back to Docker workstation: devzone workspace revert" >&2
99
98
  exit 1
100
99
  ;;
101
100
  esac
@@ -1,9 +1,9 @@
1
1
  #!/usr/bin/env bash
2
2
  # devzone workspace services (#528): installs or removes the devzone services
3
- # (gitlab, postgres, argocd) of a Kubernetes workspace from the workstation.
3
+ # (gitlab, postgres, mysql, argocd) of a Kubernetes workspace from the workstation.
4
4
  # Sourced by manage/workspace.sh (drapeau_kubectl, POD, NAMESPACE).
5
5
  # devzone workspace services enable <service> [options]
6
- # devzone workspace services disable <service> [--oui]
6
+ # devzone workspace services disable <service> [--yes]
7
7
  # devzone workspace services status
8
8
  # Why: the pod has no administrator access to the cluster (#430), while the
9
9
  # installers need one. The workstation creates a ServiceAccount bound to
@@ -19,12 +19,12 @@ SERVICES_ADMIN_SCRIPT="${DEVZONE_SERVICES_ADMIN_SCRIPT:-/usr/local/share/devzone
19
19
  SERVICES_TOKEN_DURATION="${DEVZONE_SERVICES_TOKEN_DURATION:-1h}"
20
20
 
21
21
  services_usage() {
22
- echo "devzone workspace services enable|disable <gitlab|postgres|argocd> [options] | status"
22
+ echo "devzone workspace services enable|disable <gitlab|postgres|mysql|argocd> [options] | status"
23
23
  }
24
24
 
25
25
  services_known() {
26
26
  case "${1:-}" in
27
- gitlab | postgres | argocd) return 0 ;;
27
+ gitlab | postgres | mysql | argocd) return 0 ;;
28
28
  esac
29
29
  return 1
30
30
  }
@@ -34,6 +34,7 @@ services_namespace() {
34
34
  case "$1" in
35
35
  gitlab) echo devzone-gitlab ;;
36
36
  postgres) echo devzone-postgres ;;
37
+ mysql) echo devzone-mysql ;;
37
38
  argocd) echo devzone-argocd ;;
38
39
  esac
39
40
  }
@@ -91,6 +92,20 @@ services_run() {
91
92
  echo "✖ unknown service: ${service:-(none)} ($(services_usage))" >&2
92
93
  return 1
93
94
  fi
95
+ # Argo CD itself, and postgres and mysql when Argo CD holds the devzone
96
+ # charts: done by the workstation, no installer in the pod (#516, #538)
97
+ if [ "$service" = argocd ]; then
98
+ argocd_toggle "$action" "$@"
99
+ return
100
+ fi
101
+ case "$service" in
102
+ postgres | mysql)
103
+ if argocd_holds_charts; then
104
+ services_argocd_toggle "$service" "$action" "$@"
105
+ return
106
+ fi
107
+ ;;
108
+ esac
94
109
  if ! services_pod_running; then
95
110
  echo "✖ workspace pod $POD not running: devzone workspace start" >&2
96
111
  return 1
@@ -110,6 +125,8 @@ services_run() {
110
125
  return 1
111
126
  fi
112
127
  echo "▶ $action $service in the pod $POD…"
128
+ # The installer of the pod still spells --oui (#510): --yes translated
129
+ set -- "${@/--yes/--oui}"
113
130
  # shellcheck disable=SC2046
114
131
  printf '%s\n' "$token" | kubectl $(drapeau_kubectl) exec -i "$POD" --namespace "$NAMESPACE" \
115
132
  -c workspace -- bash "$SERVICES_ADMIN_SCRIPT" "$action" "$service" "$@" || code=$?
@@ -125,7 +142,7 @@ services_run() {
125
142
  # One line per service: installed (namespace present) or not
126
143
  services_status() {
127
144
  local s ns
128
- for s in gitlab postgres argocd; do
145
+ for s in gitlab postgres mysql argocd; do
129
146
  ns="$(services_namespace "$s")"
130
147
  # shellcheck disable=SC2046
131
148
  if kubectl $(drapeau_kubectl) get namespace "$ns" >/dev/null 2>&1; then