devzone 2.0.0 → 3.0.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 (90) hide show
  1. package/.devcontainer/agent-errors.sh +6 -6
  2. package/.devcontainer/agent-pod-manifest.sh +4 -4
  3. package/.devcontainer/agent-session.sh +2 -2
  4. package/.devcontainer/agent-state-json.sh +2 -2
  5. package/.devcontainer/agent-workspace.sh +1 -1
  6. package/.devcontainer/agent.sh +7 -7
  7. package/.devcontainer/ai/host-models.sh +2 -2
  8. package/.devcontainer/ai/plugins/devzone-guard-v2.js +3 -3
  9. package/.devcontainer/ai/plugins/devzone-guard.js +3 -3
  10. package/.devcontainer/argocd/argocd.sh +90 -89
  11. package/.devcontainer/argocd/catalog-argocd.sh +2 -2
  12. package/.devcontainer/argocd/services-hook.sh +3 -3
  13. package/.devcontainer/argocd/services.sh +1 -1
  14. package/.devcontainer/catalog/app.sh +114 -116
  15. package/.devcontainer/catalog/catalog-watcher.sh +62 -62
  16. package/.devcontainer/catalog/mysql/app.conf +1 -1
  17. package/.devcontainer/catalog/mysql/install.sh +40 -40
  18. package/.devcontainer/catalog/mysql/mysql.sh +141 -141
  19. package/.devcontainer/catalog/mysql/volume.sh +39 -39
  20. package/.devcontainer/catalog.sh +112 -112
  21. package/.devcontainer/chart-direct.sh +1 -1
  22. package/.devcontainer/cluster.sh +216 -218
  23. package/.devcontainer/clusters.sh +41 -41
  24. package/.devcontainer/devzone +92 -1495
  25. package/.devcontainer/devzone-ai-guard.sh +76 -0
  26. package/.devcontainer/devzone-ai.sh +201 -0
  27. package/.devcontainer/devzone-cluster.sh +210 -0
  28. package/.devcontainer/devzone-modules.sh +126 -0
  29. package/.devcontainer/devzone-platform.sh +189 -0
  30. package/.devcontainer/devzone-repair.sh +94 -0
  31. package/.devcontainer/devzone-services.sh +241 -0
  32. package/.devcontainer/devzone-skill.sh +97 -0
  33. package/.devcontainer/devzone-status.sh +140 -0
  34. package/.devcontainer/devzone-version.sh +78 -0
  35. package/.devcontainer/git-identity.sh +28 -0
  36. package/.devcontainer/gitlab/chart.sh +2 -2
  37. package/.devcontainer/gitlab/gitlab.sh +81 -82
  38. package/.devcontainer/gitlab/installation.sh +109 -109
  39. package/.devcontainer/gitlab/secrets.sh +47 -47
  40. package/.devcontainer/gitlab/seed.sh +77 -77
  41. package/.devcontainer/gitlab/test-gitlab.sh +242 -243
  42. package/.devcontainer/help.sh +1 -1
  43. package/.devcontainer/isolation.sh +30 -30
  44. package/.devcontainer/kind-wrapper.sh +17 -17
  45. package/.devcontainer/kube-account.sh +112 -113
  46. package/.devcontainer/kube-config.sh +45 -46
  47. package/.devcontainer/{invite-kube.sh → kube-prompt.sh} +6 -6
  48. package/.devcontainer/kube-reachable.sh +40 -40
  49. package/.devcontainer/memory.sh +1 -1
  50. package/.devcontainer/metrics-server.sh +2 -2
  51. package/.devcontainer/opencode.jsonc +2 -2
  52. package/.devcontainer/packages.sh +136 -135
  53. package/.devcontainer/password.sh +1 -1
  54. package/.devcontainer/ports-auto.sh +152 -153
  55. package/.devcontainer/ports-json.sh +16 -15
  56. package/.devcontainer/ports.sh +126 -122
  57. package/.devcontainer/post-create.sh +52 -52
  58. package/.devcontainer/postgres/postgres.sh +174 -174
  59. package/.devcontainer/rename-legacy-files.sh +103 -0
  60. package/.devcontainer/services-admin.sh +3 -3
  61. package/.devcontainer/skills/devzone/SKILL.md +40 -41
  62. package/.devcontainer/startup.sh +48 -49
  63. package/.devcontainer/state-gitops.sh +1 -1
  64. package/.devcontainer/state-json.sh +36 -62
  65. package/.devcontainer/state.sh +2 -2
  66. package/.devcontainer/workspace-init.sh +16 -2
  67. package/Makefile +1 -1
  68. package/README.md +195 -194
  69. package/charts/devzone-workspace/templates/statefulset.yaml +1 -1
  70. package/manage/devzone +5 -7
  71. package/manage/scripts/argocd-workspace.sh +1 -1
  72. package/manage/scripts/check-names.sh +6 -5
  73. package/manage/scripts/create-cluster.sh +1 -1
  74. package/manage/scripts/create-mode.sh +2 -2
  75. package/manage/scripts/devzone-create.sh +3 -3
  76. package/manage/scripts/devzone-manifest.sh +1 -1
  77. package/manage/scripts/devzone-update.sh +12 -8
  78. package/manage/scripts/launch.sh +7 -48
  79. package/manage/scripts/migrate-revert.sh +3 -3
  80. package/manage/scripts/migrate.sh +7 -13
  81. package/manage/scripts/ports-apps.sh +1 -1
  82. package/manage/scripts/ports-workspace.sh +7 -7
  83. package/manage/scripts/uninstall.sh +8 -8
  84. package/manage/scripts/workspace-egress.sh +2 -2
  85. package/manage/scripts/workspace-update.sh +5 -2
  86. package/manage/scripts/workspace-wait.sh +2 -2
  87. package/package.json +1 -1
  88. package/.devcontainer/docker-relay.sh +0 -149
  89. package/.devcontainer/docker-without-host.sh +0 -12
  90. package/.devcontainer/git-identite.sh +0 -28
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env bash
2
- # Opérations d'installation du catalogue (#414) : sourcé par catalog.sh.
3
- # Le module argocd actif : l'application installée est une Application Argo CD
4
- # devzone-<app> (chart charts/devzone-<app> du dépôt devzone, #538) au lieu du
5
- # manifeste de la voie helm direct.
2
+ # Install operations of the catalog (#414): sourced by catalog.sh.
3
+ # With the argocd module on, the installed application is an Argo CD Application
4
+ # devzone-<app> (chart charts/devzone-<app> of the devzone repository, #538) instead
5
+ # of the manifest of the direct helm path.
6
6
 
7
- ATTENTE="${DEVZONE_CATALOGUE_ATTENTE:-300}"
7
+ WAIT_SECONDS="${DEVZONE_CATALOG_WAIT:-300}"
8
8
 
9
9
  # shellcheck source=SCRIPTDIR/argocd/catalog-argocd.sh
10
10
  # shellcheck disable=SC1091
@@ -13,119 +13,117 @@ ATTENTE="${DEVZONE_CATALOGUE_ATTENTE:-300}"
13
13
  # shellcheck disable=SC1091
14
14
  . "$ICI/chart-direct.sh"
15
15
 
16
- # Attente du StatefulSet prêt : une seule commande rollout sur la voie
17
- # manifeste, sondée sur la voie Argo CD (la synchronisation est en tâche de
18
- # fond)
19
- app_attendre() {
20
- local app="$1" ns="$2" argo="$3" fin=$((SECONDS + ATTENTE))
16
+ # Waits for the StatefulSet to be ready: a single rollout command on the manifest
17
+ # path, polled on the Argo CD path (the sync runs in the background)
18
+ app_wait() {
19
+ local app="$1" ns="$2" argo="$3" end=$((SECONDS + WAIT_SECONDS))
21
20
  if [ "$argo" = 1 ]; then
22
- while [ "$SECONDS" -lt "$fin" ]; do
21
+ while [ "$SECONDS" -lt "$end" ]; do
23
22
  kubectl --context devzone -n "$ns" rollout status "statefulset/$app" --timeout=10s >/dev/null 2>&1 && return 0
24
23
  sleep 5
25
24
  done
26
- echo "devzone : catalogue : $app pas prêt après ${ATTENTE}s" >&2
25
+ echo "devzone : catalog : $app not ready after ${WAIT_SECONDS}s" >&2
27
26
  return 1
28
27
  fi
29
28
  if ! kubectl --context devzone -n "$ns" rollout status "statefulset/$app" \
30
- --timeout="${ATTENTE}s" >/dev/null; then
31
- echo "devzone : catalogue : $app pas prêt après ${ATTENTE}s" >&2
29
+ --timeout="${WAIT_SECONDS}s" >/dev/null; then
30
+ echo "devzone : catalog : $app not ready after ${WAIT_SECONDS}s" >&2
32
31
  return 1
33
32
  fi
34
33
  }
35
34
 
36
- # Secret de l'application : mot de passe généré une fois, miroir local
37
- # (workspace/.$app/admin-password, 600, jamais affiché). Reprise : le mot de
38
- # passe déjà là (secret cluster ou root.env) est conservé, jamais régénéré.
35
+ # Application secret: password generated once, local mirror
36
+ # (workspace/.$app/admin-password, 600, never shown). Re-run: a password already
37
+ # there (cluster secret or root.env) is kept, never regenerated.
39
38
  app_secret() {
40
- local app="$1" ns="$2" mdp fichier
41
- fichier="$RACINE/workspace/.$app/admin-password"
42
- mkdir -p "$(dirname "$fichier")"
43
- chmod 700 "$(dirname "$fichier")"
39
+ local app="$1" ns="$2" password file
40
+ file="$RACINE/workspace/.$app/admin-password"
41
+ mkdir -p "$(dirname "$file")"
42
+ chmod 700 "$(dirname "$file")"
44
43
  if kubectl --context devzone -n "$ns" get secret "$app-admin" >/dev/null 2>&1; then
45
- mdp="$(kubectl --context devzone -n "$ns" get secret "$app-admin" \
44
+ password="$(kubectl --context devzone -n "$ns" get secret "$app-admin" \
46
45
  -o jsonpath='{.data.password}' | tr -d '\n')"
47
- (umask 077 && printf '%s' "$mdp" >"$fichier")
46
+ (umask 077 && printf '%s' "$password" >"$file")
48
47
  return 0
49
48
  fi
50
- mdp="$(sed -n 's/^\(MYSQL_\|\)PASSWORD=//p' "$RACINE/workspace/.$app/root.env" 2>/dev/null | tail -1 || true)"
51
- if [ -z "$mdp" ] && [ -s "$fichier" ]; then mdp="$(cat "$fichier")"; fi
52
- if [ -z "$mdp" ]; then
53
- (umask 077 && openssl rand -hex 24 | tr -d '\n' >"$fichier")
54
- elif [ ! -s "$fichier" ]; then
55
- (umask 077 && printf '%s' "$mdp" >"$fichier")
49
+ password="$(sed -n 's/^\(MYSQL_\|\)PASSWORD=//p' "$RACINE/workspace/.$app/root.env" 2>/dev/null | tail -1 || true)"
50
+ if [ -z "$password" ] && [ -s "$file" ]; then password="$(cat "$file")"; fi
51
+ if [ -z "$password" ]; then
52
+ (umask 077 && openssl rand -hex 24 | tr -d '\n' >"$file")
53
+ elif [ ! -s "$file" ]; then
54
+ (umask 077 && printf '%s' "$password" >"$file")
56
55
  fi
57
56
  kubectl --context devzone -n "$ns" create secret generic "$app-admin" \
58
- --from-file=password="$fichier" >/dev/null
57
+ --from-file=password="$file" >/dev/null
59
58
  }
60
59
 
61
- # Vue regroupée des identifiants : un échec n'empêche jamais l'opération
60
+ # Grouped view of the credentials: a failure never blocks the operation
62
61
  regenerer_identifiants() {
63
62
  password_regenerate ||
64
- echo "devzone : catalogue : identifiants regroupés non mis à jour (devzone passwords)" >&2
63
+ echo "devzone : catalog : grouped credentials not updated (devzone passwords)" >&2
65
64
  }
66
65
 
67
- # Installe une application : contexte devzone posé (#396), namespace créé et
68
- # isolé (#396), secret généré, puis Application Argo CD (module argocd actif,
69
- # #538) ou manifeste, attente prête, relais lancé vers 127.0.0.1:<port> du
70
- # conteneur ; rend non nul en échec
71
- app_installer() {
66
+ # Installs an application: devzone context set (#396), namespace created and
67
+ # isolated (#396), secret generated, then the Argo CD Application (argocd module
68
+ # on, #538) or the manifest, wait until ready, relay started to 127.0.0.1:<port>
69
+ # of the container; returns non-zero on failure
70
+ app_install() {
72
71
  local app="$1" ns port image CTX extra="" argo=0
73
- ns="$(app_ns "$app")"
74
- port="$(app_lire "$app" port)"
75
- image="$(app_lire "$app" image)"
76
- CTX="$(cluster_lu)"
77
- [ -n "$CTX" ] || refuse "aucun cluster choisi : devzone enable $app"
78
- if ! contexte_devzone_poser "$CTX"; then
79
- echo "devzone : catalogue : impossible de poser le contexte devzone sur $CTX" >&2
72
+ ns="$(app_namespace "$app")"
73
+ port="$(app_read "$app" port)"
74
+ image="$(app_read "$app" image)"
75
+ CTX="$(cluster_saved)"
76
+ [ -n "$CTX" ] || refuse "no cluster chosen: devzone enable $app"
77
+ if ! devzone_context_set "$CTX"; then
78
+ echo "devzone : catalog : cannot set the devzone context on $CTX" >&2
80
79
  return 1
81
80
  fi
82
- echo "▶ Application $app sur le cluster $CTX (namespace $ns)…"
83
- # Namespace créé et étiqueté par l'administrateur (#430), puis compte
84
- # limité autorisé dans le namespace
85
- compte_admin "$CTX" create namespace "$ns" --dry-run=client -o yaml |
86
- compte_admin "$CTX" apply -f - >/dev/null
87
- compte_admin "$CTX" label namespace "$ns" "$CLUSTER_ETIQUETTE" --overwrite >/dev/null
88
- compte_autoriser "$CTX" "$ns"
89
- namespace_isoler "$ns" >/dev/null
81
+ echo "▶ Application $app on cluster $CTX (namespace $ns)…"
82
+ # Namespace created and labelled by the administrator (#430), then the limited
83
+ # account allowed in the namespace
84
+ account_admin "$CTX" create namespace "$ns" --dry-run=client -o yaml |
85
+ account_admin "$CTX" apply -f - >/dev/null
86
+ account_admin "$CTX" label namespace "$ns" "$CLUSTER_LABEL" --overwrite >/dev/null
87
+ account_allow "$CTX" "$ns"
88
+ namespace_isolate "$ns" >/dev/null
90
89
  app_secret "$app" "$ns"
91
90
  local claim=donnees
92
91
  if [ "$app" = mysql ]; then
93
92
  # shellcheck source=SCRIPTDIR/mysql/volume.sh
94
93
  # shellcheck disable=SC1091
95
- . "$(dossier_catalogue)/mysql/volume.sh"
96
- claim="$(mysql_claim_choisir "$ns")" || return 2
94
+ . "$(catalog_dir)/mysql/volume.sh"
95
+ claim="$(mysql_claim_choose "$ns")" || return 2
97
96
  [ "$claim" = donnees ] || extra="claim=$claim"
98
97
  fi
99
98
  if catalogue_argocd_active "$app"; then
100
99
  argo=1
101
- echo "▶ Application $app par Argo CD (chart charts/devzone-$app)…"
100
+ echo "▶ Application $app through Argo CD (chart charts/devzone-$app)…"
102
101
  catalogue_argocd_apply "$app" "$ns" "$image" "$port" \
103
- "$(app_lire "$app" memoire)" "$(app_lire "$app" taille)" "$extra" || return 1
102
+ "$(app_read "$app" memoire)" "$(app_read "$app" taille)" "$extra" || return 1
104
103
  else
105
- # Helm direct: the chart charts/devzone-<app>, the one definition (#559)
104
+ # Direct helm: the chart charts/devzone-<app>, the one definition (#559)
106
105
  chart_install "$app" "$ns" "image=$image" "port=$port" \
107
- "memory=$(app_lire "$app" memoire)" "size=$(app_lire "$app" taille)" "claim=$claim" || return 1
106
+ "memory=$(app_read "$app" memoire)" "size=$(app_read "$app" taille)" "claim=$claim" || return 1
108
107
  fi
109
- app_attendre "$app" "$ns" "$argo" || return 1
110
- relais_lancer "$app" "$CTX" "$ns" "svc/$app" "$port:$port"
111
- echo "✔ $app prêt : 127.0.0.1:$port dans le conteneur"
108
+ app_wait "$app" "$ns" "$argo" || return 1
109
+ relay_start "$app" "$CTX" "$ns" "svc/$app" "$port:$port"
110
+ echo "✔ $app ready: 127.0.0.1:$port in the container"
112
111
  regenerer_identifiants
113
112
  }
114
113
 
115
- # Désinstalle une application : relais coupé, Application Argo CD retirée
116
- # (module argocd actif, #538) ou manifeste, marque oubliée ; le volume (PVC)
117
- # et les données restent (#441) : la suppression des données est confirmée à
118
- # part (devzone mysql delete-data)
119
- app_desinstaller() {
114
+ # Uninstalls an application: relay stopped, Argo CD Application removed (argocd
115
+ # module on, #538) or the manifest, failure marker forgotten. The volume (PVC) and
116
+ # the data stay (#441): deleting the data is confirmed apart (devzone mysql delete-data)
117
+ app_remove() {
120
118
  local app="$1" ns claim pvc CTX
121
- ns="$(app_ns "$app")"
122
- relais_arreter "$app"
123
- rm -f "$(fichier_echec "$app")"
124
- # RoleBinding retiré par l'administrateur (#430) : le namespace et le
125
- # volume restent, l'autorisation du compte ne doit pas traîner
126
- CTX="$(cluster_lu)" || true
119
+ ns="$(app_namespace "$app")"
120
+ relay_stop "$app"
121
+ rm -f "$(failure_file "$app")"
122
+ # RoleBinding removed by the administrator (#430): the namespace and the volume
123
+ # stay, the account authorization must not linger
124
+ CTX="$(cluster_saved)" || true
127
125
  if [ -n "$CTX" ]; then
128
- compte_retirer "$CTX" "$ns" >/dev/null 2>&1 || true
126
+ account_remove "$CTX" "$ns" >/dev/null 2>&1 || true
129
127
  fi
130
128
  claim="$(kubectl --context devzone -n "$ns" get statefulset "$app" \
131
129
  -o jsonpath='{.spec.volumeClaimTemplates[0].metadata.name}' 2>/dev/null || true)"
@@ -133,79 +131,79 @@ app_desinstaller() {
133
131
  catalogue_argocd_delete "$app" >/dev/null 2>&1 || true
134
132
  kubectl --context devzone -n "$ns" delete "secret/$app-admin" >/dev/null 2>&1 || true
135
133
  pvc="${claim:-donnees}-$app-0"
136
- echo "✔ $app retiré : Application supprimée ; volume $pvc et bases gardés : devzone $app volume"
134
+ echo "✔ $app removed: Application deleted; volume $pvc and databases kept: devzone $app volume"
137
135
  regenerer_identifiants
138
136
  return 0
139
137
  fi
140
138
  kubectl --context devzone -n "$ns" delete "statefulset/$app" "service/$app" \
141
139
  "secret/$app-admin" >/dev/null 2>&1 || true
142
140
  pvc="${claim:-donnees}-$app-0"
143
- echo "✔ $app retiré du cluster ; volume $pvc et bases gardés : devzone $app volume"
141
+ echo "✔ $app removed from the cluster; volume $pvc and databases kept: devzone $app volume"
144
142
  regenerer_identifiants
145
143
  }
146
144
 
147
- # Marque d'échec d'une tentative : dernière ligne du message gardée et montrée
148
- app_echec() {
149
- printf '%s\n' "$2" | tail -1 >"$(fichier_echec "$1")"
145
+ # Failure marker of an attempt: last line of the message kept and shown
146
+ app_failure() {
147
+ printf '%s\n' "$2" | tail -1 >"$(failure_file "$1")"
150
148
  printf '%s\n' "$2" >&2
151
149
  }
152
150
 
153
- # Avertit des PVC mysql non montés par le StatefulSet (#440). Lecture des
154
- # namespaces réservée à l'administrateur (#430).
155
- app_mysql_volumes_inutilises() {
156
- local ctx ns monte pvc liste
157
- ctx="$(cluster_lu)"
151
+ # Warns about the mysql PVCs not mounted by the StatefulSet (#440). Reading the
152
+ # namespaces is reserved to the administrator (#430).
153
+ app_unused_mysql_volumes() {
154
+ local ctx ns mounted pvc list
155
+ ctx="$(cluster_saved)"
158
156
  [ -n "$ctx" ] || return 0
159
- ns="$(app_ns mysql)"
160
- compte_admin "$ctx" get namespace "$ns" >/dev/null 2>&1 || return 0
161
- monte="$(kubectl --context devzone -n "$ns" get statefulset mysql -o jsonpath='{.spec.volumeClaimTemplates[0].metadata.name}' 2>/dev/null || true)"
162
- [ -n "$monte" ] || return 0
163
- liste="$(kubectl --context devzone -n "$ns" get pvc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' 2>/dev/null | grep -E '\-mysql-0$' || true)"
157
+ ns="$(app_namespace mysql)"
158
+ account_admin "$ctx" get namespace "$ns" >/dev/null 2>&1 || return 0
159
+ mounted="$(kubectl --context devzone -n "$ns" get statefulset mysql -o jsonpath='{.spec.volumeClaimTemplates[0].metadata.name}' 2>/dev/null || true)"
160
+ [ -n "$mounted" ] || return 0
161
+ list="$(kubectl --context devzone -n "$ns" get pvc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' 2>/dev/null | grep -E '\-mysql-0$' || true)"
164
162
  while IFS= read -r pvc; do
165
163
  [ -n "$pvc" ] || continue
166
- [ "$pvc" != "${monte}-mysql-0" ] || continue
167
- printf ' ⚠ volume %s non utilisé : devzone mysql volume\n' "$pvc"
168
- done <<<"$liste"
164
+ [ "$pvc" != "${mounted}-mysql-0" ] || continue
165
+ printf ' ⚠ volume %s not used : devzone mysql volume\n' "$pvc"
166
+ done <<<"$list"
169
167
  }
170
168
 
171
- # Comble l'écart entre le voulu et le réel : installe, retire, relance le
172
- # relais permanent ; marque l'échec au premier problème puis passe à la suite
173
- catalogue_appliquer() {
174
- local app sortie code=0 port CTX ns
169
+ # Closes the gap between wanted and actual: installs, removes, restarts the
170
+ # permanent relay; marks the first failure then moves on
171
+ catalog_apply() {
172
+ local app output code=0 port CTX ns
175
173
  while IFS= read -r app; do
176
174
  [ -n "$app" ] || continue
177
- port="$(app_lire "$app" port)"
178
- if [ "$(voulu "$app")" != on ] && presente "$app"; then
179
- if ! sortie="$(app_desinstaller "$app" 2>&1)"; then
180
- code=1; app_echec "$app" "$sortie"
175
+ port="$(app_read "$app" port)"
176
+ if [ "$(wanted "$app")" != on ] && present "$app"; then
177
+ if ! output="$(app_remove "$app" 2>&1)"; then
178
+ code=1; app_failure "$app" "$output"
181
179
  else
182
- printf '%s\n' "$sortie"
180
+ printf '%s\n' "$output"
183
181
  fi
184
- elif [ "$(voulu "$app")" = on ] && presente "$app"; then
185
- if ! app_prete "$app"; then
182
+ elif [ "$(wanted "$app")" = on ] && present "$app"; then
183
+ if ! app_ready "$app"; then
186
184
  code=1
187
- echo "devzone : catalogue : $app installé mais pas prêt : devzone apply" >&2
188
- echo "pas prêt" >"$(fichier_echec "$app")"
185
+ echo "devzone : catalog : $app installed but not ready: devzone apply" >&2
186
+ echo "not ready" >"$(failure_file "$app")"
189
187
  else
190
- rm -f "$(fichier_echec "$app")"
188
+ rm -f "$(failure_file "$app")"
191
189
  fi
192
- # Relais permanent : relancé s'il est arrêté
193
- CTX="$(cluster_lu)" || true
194
- ns="$(app_ns "$app")"
190
+ # Permanent relay: restarted if stopped
191
+ CTX="$(cluster_saved)" || true
192
+ ns="$(app_namespace "$app")"
195
193
  if [ -n "$CTX" ]; then
196
- if ! sortie="$(relais_lancer "$app" "$CTX" "$ns" "svc/$app" "$port:$port" 2>&1)"; then
197
- code=1; app_echec "$app" "$sortie"
194
+ if ! output="$(relay_start "$app" "$CTX" "$ns" "svc/$app" "$port:$port" 2>&1)"; then
195
+ code=1; app_failure "$app" "$output"
198
196
  else
199
- [ -n "$sortie" ] && printf '%s\n' "$sortie"
197
+ [ -n "$output" ] && printf '%s\n' "$output"
200
198
  fi
201
199
  fi
202
- elif [ "$(voulu "$app")" = on ]; then
203
- if ! sortie="$(app_installer "$app" 2>&1)"; then
204
- code=1; app_echec "$app" "$sortie"
200
+ elif [ "$(wanted "$app")" = on ]; then
201
+ if ! output="$(app_install "$app" 2>&1)"; then
202
+ code=1; app_failure "$app" "$output"
205
203
  else
206
- printf '%s\n' "$sortie"
204
+ printf '%s\n' "$output"
207
205
  fi
208
206
  fi
209
- done <<<"$(catalogue_apps)"
207
+ done <<<"$(catalog_apps)"
210
208
  return "$code"
211
209
  }
@@ -1,130 +1,130 @@
1
1
  #!/usr/bin/env bash
2
- # Détection à chaud du catalogue (#414) : quand .devzone.modules change,
3
- # catalog.sh appliquer est lancé. Une seule instance (verrou, comme #394).
2
+ # Catalog hot detection (#414): when .devzone.modules changes, catalog.sh apply
3
+ # runs. A single instance (lock, as #394).
4
4
  # catalog-watcher.sh demarrer | arreter | tour
5
5
  set -euo pipefail
6
6
 
7
7
  ICI="$(cd "$(dirname "$0")" && pwd)"
8
- RACINE="${DEVZONE_RACINE:-$(cd "$ICI/../.." && pwd)}"
9
- ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
8
+ RACINE="${DEVZONE_ROOT:-$(cd "$ICI/../.." && pwd)}"
9
+ ETAT="${DEVZONE_STATE:-$RACINE/.devzone.modules}"
10
10
  # shellcheck source=SCRIPTDIR/state.sh
11
11
  # shellcheck disable=SC1091
12
12
  . "$(dirname "$ICI")/state.sh"
13
- BASE="${DEVZONE_CATALOGUE_VEILLEUR_DIR:-$RACINE/.devzone.catalogue-veilleur}"
14
- VERROU="$BASE/verrou"
15
- DERNIER="$BASE/dernier"
13
+ BASE="${DEVZONE_CATALOG_WATCHER_DIR:-$RACINE/.devzone.catalog-watcher}"
14
+ LOCK_DIR="$BASE/verrou"
15
+ LAST_FILE="$BASE/dernier"
16
16
 
17
- refuse() { echo "devzone : catalogue-veilleur : $*" >&2; exit 2; }
17
+ refuse() { echo "devzone : catalog-watcher : $*" >&2; exit 2; }
18
18
 
19
- # Garde-fou (#293) : jamais sous bats, seulement avec DEVZONE_CATALOGUE_REEL=oui
20
- garde_veilleur() {
21
- if [ "${DEVZONE_CATALOGUE_REEL:-}" != oui ]; then
22
- echo "devzone : catalogue-veilleur : refusé ici (DEVZONE_CATALOGUE_REEL=oui)" >&2
19
+ # Guard (#293): never under bats, only with DEVZONE_CATALOG_REAL=yes
20
+ guard_watcher() {
21
+ if [ "${DEVZONE_CATALOG_REAL:-}" != yes ]; then
22
+ echo "devzone : catalog-watcher : refused here (DEVZONE_CATALOG_REAL=yes)" >&2
23
23
  return 2
24
24
  fi
25
25
  if [ -n "${BATS_TEST_TMPDIR:-}" ]; then
26
- echo "devzone : catalogue-veilleur : refusé sous bats (tests)" >&2
26
+ echo "devzone : catalog-watcher : refused under bats (tests)" >&2
27
27
  return 2
28
28
  fi
29
29
  return 0
30
30
  }
31
31
 
32
- # Verrou exclusif (mkdir) avec pid ; une seule instance du veilleur
33
- verrou_prendre() {
34
- local debut now age pid
35
- debut="$(date +%s)"
32
+ # Exclusive lock (mkdir) with the pid; a single watcher instance
33
+ lock_take() {
34
+ local start now age pid
35
+ start="$(date +%s)"
36
36
  while true; do
37
- if mkdir "$VERROU" 2>/dev/null; then echo "$$" >"$VERROU/pid"; return 0; fi
37
+ if mkdir "$LOCK_DIR" 2>/dev/null; then echo "$$" >"$LOCK_DIR/pid"; return 0; fi
38
38
  now="$(date +%s)"
39
- age=""; [ -d "$VERROU" ] && age="$(stat -c %Y "$VERROU" 2>/dev/null || stat -f %m "$VERROU" 2>/dev/null || true)"
40
- pid="$(cat "$VERROU/pid" 2>/dev/null || true)"
41
- if [ -n "$age" ] && [ "$(( now - age ))" -gt 30 ]; then rm -rf "$VERROU"; continue; fi
42
- if [ -n "$pid" ] && ! kill -0 "$pid" 2>/dev/null; then rm -rf "$VERROU"; continue; fi
43
- [ "$(( now - debut ))" -ge 5 ] && return 1
39
+ age=""; [ -d "$LOCK_DIR" ] && age="$(stat -c %Y "$LOCK_DIR" 2>/dev/null || stat -f %m "$LOCK_DIR" 2>/dev/null || true)"
40
+ pid="$(cat "$LOCK_DIR/pid" 2>/dev/null || true)"
41
+ if [ -n "$age" ] && [ "$(( now - age ))" -gt 30 ]; then rm -rf "$LOCK_DIR"; continue; fi
42
+ if [ -n "$pid" ] && ! kill -0 "$pid" 2>/dev/null; then rm -rf "$LOCK_DIR"; continue; fi
43
+ [ "$(( now - start ))" -ge 5 ] && return 1
44
44
  sleep 1
45
45
  done
46
46
  }
47
47
 
48
- # Marque le verrou vivant (date et pid à jour)
49
- verrou_rafraichir() { touch "$VERROU" 2>/dev/null || true; echo "$$" >"$VERROU/pid" 2>/dev/null || true; }
48
+ # Marks the live lock (date and pid up to date)
49
+ lock_refresh() { touch "$LOCK_DIR" 2>/dev/null || true; echo "$$" >"$LOCK_DIR/pid" 2>/dev/null || true; }
50
50
 
51
- # Un tour : si .devzone.modules a changé depuis le dernier tour, on applique
52
- tour() {
53
- local maintenant ancien
51
+ # One tick: if .devzone.modules changed since the last tick, apply
52
+ tick() {
53
+ local now previous
54
54
  [ -f "$ETAT" ] || return 0
55
- # État restauré ou reconstruit : le veilleur ne suit pas un état douteux,
56
- # et ne désinstalle jamais tant que devzone apply ne l'a pas confirmé
55
+ # Restored or rebuilt state: the watcher does not follow a doubtful state,
56
+ # and never uninstalls until devzone apply has confirmed it
57
57
  state_recovery_wait && return 0
58
58
  state_recovery_pending && return 0
59
59
  mkdir -p "$BASE"
60
- maintenant="$(stat -c %Y "$ETAT" 2>/dev/null || stat -f %m "$ETAT" 2>/dev/null || true)"
61
- [ -n "$maintenant" ] || return 0
62
- ancien="$(cat "$DERNIER" 2>/dev/null || true)"
63
- if [ "$maintenant" != "$ancien" ]; then
64
- echo "$maintenant" >"$DERNIER"
65
- echo "devzone : catalogue-veilleur : .devzone.modules modifié, application" >&2
60
+ now="$(stat -c %Y "$ETAT" 2>/dev/null || stat -f %m "$ETAT" 2>/dev/null || true)"
61
+ [ -n "$now" ] || return 0
62
+ previous="$(cat "$LAST_FILE" 2>/dev/null || true)"
63
+ if [ "$now" != "$previous" ]; then
64
+ echo "$now" >"$LAST_FILE"
65
+ echo "devzone : catalog-watcher : .devzone.modules changed, applying" >&2
66
66
  bash "$ICI/../catalog.sh" apply
67
67
  fi
68
68
  }
69
69
 
70
- # Boucle : un tour toutes les 5 s, verrou rafraîchi à chaque tour
71
- boucle() {
70
+ # Loop: one tick every 5 s, lock refreshed on each tick
71
+ loop() {
72
72
  mkdir -p "$BASE"
73
- if ! verrou_prendre; then return 0; fi
74
- trap 'rm -rf "$VERROU"' EXIT INT TERM
73
+ if ! lock_take; then return 0; fi
74
+ trap 'rm -rf "$LOCK_DIR"' EXIT INT TERM
75
75
  while true; do
76
- [ -f "$ETAT" ] || { rm -rf "$VERROU"; break; }
77
- verrou_rafraichir
78
- tour || true
76
+ [ -f "$ETAT" ] || { rm -rf "$LOCK_DIR"; break; }
77
+ lock_refresh
78
+ tick || true
79
79
  sleep 5
80
80
  done
81
81
  }
82
82
 
83
- # Lance la boucle détachée (#435) et vérifie que son verrou vit
84
- lancer_detache() {
83
+ # Starts the detached loop (#435) and checks that its lock is alive
84
+ start_detached() {
85
85
  local i pid stable=0 detache=()
86
86
  mkdir -p "$BASE"
87
- # Même détachement que relais_lancer : setsid si présent, sinon nohup.
87
+ # Same detachment as relay_start: setsid when present, else nohup.
88
88
  command -v setsid >/dev/null 2>&1 && detache=(setsid)
89
- ${detache[@]+"${detache[@]}"} nohup env DEVZONE_CATALOGUE_REEL=oui bash "$0" boucle >"$BASE/veilleur.log" 2>&1 &
89
+ ${detache[@]+"${detache[@]}"} nohup env DEVZONE_CATALOG_REAL=yes bash "$0" boucle >"$BASE/veilleur.log" 2>&1 &
90
90
  i=0
91
91
  while [ "$i" -lt 20 ]; do
92
- pid="$(cat "$VERROU/pid" 2>/dev/null || true)"
92
+ pid="$(cat "$LOCK_DIR/pid" 2>/dev/null || true)"
93
93
  if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then
94
94
  stable=$((stable + 1))
95
- [ "$stable" -ge 5 ] && { echo "lancé"; return 0; }
95
+ [ "$stable" -ge 5 ] && { echo "started"; return 0; }
96
96
  else
97
97
  stable=0
98
98
  fi
99
99
  sleep 0.1
100
100
  i=$((i + 1))
101
101
  done
102
- echo "devzone : catalogue-veilleur : démarrage impossible, voir $BASE/veilleur.log" >&2
102
+ echo "devzone : catalog-watcher : cannot start, see $BASE/veilleur.log" >&2
103
103
  return 1
104
104
  }
105
105
 
106
- # Arrête le veilleur et retire le verrou
107
- arreter() {
106
+ # Stops the watcher and removes the lock
107
+ stop_watcher() {
108
108
  local pid
109
- pid="$(cat "$VERROU/pid" 2>/dev/null || true)"
109
+ pid="$(cat "$LOCK_DIR/pid" 2>/dev/null || true)"
110
110
  if [ -n "$pid" ]; then kill "$pid" 2>/dev/null || true; fi
111
- rm -rf "$VERROU"
111
+ rm -rf "$LOCK_DIR"
112
112
  }
113
113
 
114
114
  case "${1:-}" in
115
- boucle | loop) if ! garde_veilleur; then exit 2; fi; boucle ;;
115
+ boucle | loop) if ! guard_watcher; then exit 2; fi; loop ;;
116
116
  demarrer | start | lancer)
117
- if ! garde_veilleur; then exit 2; fi
118
- if [ -f "$VERROU/pid" ] && kill -0 "$(cat "$VERROU/pid")" 2>/dev/null; then
119
- echo "déjà lancé"
117
+ if ! guard_watcher; then exit 2; fi
118
+ if [ -f "$LOCK_DIR/pid" ] && kill -0 "$(cat "$LOCK_DIR/pid")" 2>/dev/null; then
119
+ echo "already running"
120
120
  else
121
- lancer_detache || exit 1
121
+ start_detached || exit 1
122
122
  fi
123
123
  ;;
124
- arreter | stop) arreter ; echo "arrêté" ;;
125
- tour | un-tour) tour ;;
124
+ arreter | stop) stop_watcher ; echo "stopped" ;;
125
+ tour | un-tour) tick ;;
126
126
  *)
127
- echo "devzone : catalogue-veilleur : demarrer | arreter | tour" >&2
127
+ echo "devzone : catalog-watcher : demarrer | arreter | tour" >&2
128
128
  exit 2
129
129
  ;;
130
130
  esac
@@ -1,7 +1,7 @@
1
1
  # Application MySQL du catalogue (#414) : MySQL local de test pour les projets
2
2
  # du workspace, installé dans le cluster des services de devzone.
3
3
  # Mémoire et taille du volume : 1 Gi et 5Gi par défaut, modifiables ici.
4
- nom=mysql
4
+ name=mysql
5
5
  description=MySQL partagé, une base par projet
6
6
  image=mysql:8.4
7
7
  port=3306