devzone 0.42.0 → 0.43.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/Dockerfile +1 -1
- package/.devcontainer/agent.sh +1 -1
- package/.devcontainer/argocd/apps.sh +2 -2
- package/.devcontainer/argocd/argocd.sh +22 -10
- package/.devcontainer/argocd/catalogue-argocd.sh +4 -0
- package/.devcontainer/argocd/gitops-gitlab.sh +127 -0
- package/.devcontainer/argocd/gitops.sh +12 -2
- package/.devcontainer/argocd/services-hook.sh +181 -0
- package/.devcontainer/catalogue/app.sh +29 -12
- package/.devcontainer/catalogue/catalogue-veilleur.sh +2 -2
- package/.devcontainer/catalogue/mysql/installer.sh +9 -8
- package/.devcontainer/catalogue/mysql/mysql.sh +42 -29
- package/.devcontainer/catalogue/mysql/volume.sh +5 -5
- package/.devcontainer/catalogue.sh +30 -36
- package/.devcontainer/chart-direct.sh +49 -0
- package/.devcontainer/cluster.sh +11 -11
- package/.devcontainer/clusters.sh +1 -1
- package/.devcontainer/command-aliases.sh +152 -2
- package/.devcontainer/demarrage.sh +18 -15
- package/.devcontainer/devcontainer.json +1 -1
- package/.devcontainer/devzone +114 -122
- package/.devcontainer/docker-relais.sh +2 -2
- package/.devcontainer/docker-sans-hote.sh +1 -1
- package/.devcontainer/etat-json.sh +16 -16
- package/.devcontainer/etat.sh +4 -4
- package/.devcontainer/gitlab/argocd.sh +54 -0
- package/.devcontainer/gitlab/chart.sh +39 -0
- package/.devcontainer/gitlab/gitlab.sh +35 -180
- package/.devcontainer/gitlab/installation.sh +34 -47
- package/.devcontainer/gitlab/secrets.sh +2 -2
- package/.devcontainer/gitlab/seed.sh +204 -0
- package/.devcontainer/gitlab/test-gitlab-restes.sh +16 -0
- package/.devcontainer/gitlab/test-gitlab.sh +14 -13
- package/.devcontainer/help.sh +40 -0
- package/.devcontainer/kube-compte.sh +2 -2
- package/.devcontainer/kube-config.sh +1 -1
- package/.devcontainer/kube-joignable.sh +2 -0
- package/.devcontainer/opencode.jsonc +1 -1
- package/.devcontainer/paquets.sh +31 -18
- package/.devcontainer/ports-auto.sh +6 -6
- package/.devcontainer/ports-json.sh +34 -0
- package/.devcontainer/ports.sh +34 -43
- package/.devcontainer/post-create.sh +3 -3
- package/.devcontainer/postgres/postgres.sh +46 -32
- package/.devcontainer/services-admin.sh +13 -3
- package/.devcontainer/skills/devzone/SKILL.md +16 -16
- package/.devcontainer/versions.env +1 -1
- package/README.md +72 -40
- package/charts/devzone-gitlab/Chart.lock +9 -0
- package/charts/devzone-gitlab/Chart.yaml +15 -0
- package/charts/devzone-gitlab/values.yaml +94 -0
- package/charts/devzone-mysql/values.yaml +3 -3
- package/charts/devzone-postgres/values.yaml +2 -2
- package/manage/scripts/check-charts.sh +67 -19
- package/manage/scripts/docker-workstation.sh +73 -0
- package/manage/scripts/lancer.sh +1 -1
- package/manage/scripts/migrer-retour.sh +1 -0
- package/manage/scripts/migrer.sh +6 -0
- package/manage/scripts/services-workspace.sh +11 -3
- package/package.json +1 -1
- package/.devcontainer/catalogue/mysql/manifeste.yaml +0 -81
- package/.devcontainer/gitlab/runner-values.yaml +0 -27
- package/.devcontainer/gitlab/values.yaml +0 -83
- package/.devcontainer/postgres/postgres.yaml +0 -84
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# MySQL du catalogue (#414) :
|
|
2
|
+
# MySQL du catalogue (#414) : create, list, delete, status, relay-start, relay-stop, install, delete-data.
|
|
3
3
|
set -euo pipefail
|
|
4
4
|
ICI="$(cd "$(dirname "$0")" && pwd)"
|
|
5
5
|
RACINE="${DEVZONE_RACINE:-$(dirname "$(dirname "$(dirname "$ICI")")")}"
|
|
@@ -23,6 +23,18 @@ ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
|
|
|
23
23
|
# shellcheck source=SCRIPTDIR/../../argocd/catalogue-argocd.sh
|
|
24
24
|
# shellcheck disable=SC1091
|
|
25
25
|
. "$ICI/../../argocd/catalogue-argocd.sh"
|
|
26
|
+
# English command names are accepted (#557) : a copied script may miss the file
|
|
27
|
+
# shellcheck source=SCRIPTDIR/../../command-aliases.sh
|
|
28
|
+
# shellcheck disable=SC1091
|
|
29
|
+
if [ -f "$ICI/../../command-aliases.sh" ]; then
|
|
30
|
+
. "$ICI/../../command-aliases.sh"
|
|
31
|
+
fi
|
|
32
|
+
# Subcommand and options become their canonical English names ; the old
|
|
33
|
+
# French names warn on use (#557)
|
|
34
|
+
if command -v canonical_args >/dev/null 2>&1; then
|
|
35
|
+
canonical_args mysql "$@"
|
|
36
|
+
set -- "${ARGS_CANONICAL[@]+"${ARGS_CANONICAL[@]}"}"
|
|
37
|
+
fi
|
|
26
38
|
NS=devzone-mysql
|
|
27
39
|
SECRETS="$RACINE/workspace/.mysql"
|
|
28
40
|
MYSQL_PORT="${MYSQL_PORT:-3306}"
|
|
@@ -37,7 +49,7 @@ services_secret_mysql() { mysql_secret; }
|
|
|
37
49
|
# Régénère la vue .password (échec non bloquant)
|
|
38
50
|
regenerer_identifiants() {
|
|
39
51
|
password_regenerer ||
|
|
40
|
-
echo "devzone : catalogue mysql : identifiants regroupés non mis à jour (devzone
|
|
52
|
+
echo "devzone : catalogue mysql : identifiants regroupés non mis à jour (devzone passwords)" >&2
|
|
41
53
|
}
|
|
42
54
|
# Raccourci kubectl dans le namespace devzone-mysql
|
|
43
55
|
k() { kubectl --context devzone -n "$NS" "$@"; }
|
|
@@ -48,7 +60,7 @@ installe() { compte_admin "$(compte_ctx)" get namespace "$NS" >/dev/null 2>&1; }
|
|
|
48
60
|
contexte() {
|
|
49
61
|
local c
|
|
50
62
|
c="$(cluster_lu)"
|
|
51
|
-
[ -n "$c" ] || refuse "aucun cluster choisi : devzone
|
|
63
|
+
[ -n "$c" ] || refuse "aucun cluster choisi : devzone enable mysql"
|
|
52
64
|
echo "$c"
|
|
53
65
|
}
|
|
54
66
|
# Marque d'échec du module (même schéma que fichier_echec de devzone)
|
|
@@ -99,7 +111,7 @@ installer() {
|
|
|
99
111
|
else
|
|
100
112
|
mysql_secret
|
|
101
113
|
claim="$(mysql_claim_choisir "$NS")" || return 2
|
|
102
|
-
|
|
114
|
+
mysql_appliquer_chart "$NS" "$claim" || return 1
|
|
103
115
|
if ! k rollout status statefulset/mysql --timeout="${MYSQL_ATTENTE}s" >/dev/null; then
|
|
104
116
|
echo "devzone : catalogue mysql : pas prêt après ${MYSQL_ATTENTE}s : kubectl --context $CTX -n $NS describe pod mysql-0" >&2
|
|
105
117
|
return 1
|
|
@@ -111,17 +123,17 @@ installer() {
|
|
|
111
123
|
regenerer_identifiants
|
|
112
124
|
}
|
|
113
125
|
# Supprime le namespace (donc les PVC), garde workspace/.mysql (#441) :
|
|
114
|
-
# confirmation en terminal [o/N], --
|
|
126
|
+
# confirmation en terminal [o/N], --yes obligatoire sinon (refus, code 2)
|
|
115
127
|
supprimer_donnees() {
|
|
116
128
|
local CTX oui="" arg reponse
|
|
117
129
|
for arg in "$@"; do
|
|
118
130
|
case "$arg" in
|
|
119
|
-
--
|
|
131
|
+
--yes) oui=1 ;;
|
|
120
132
|
*) refuse "argument inconnu : $arg" ;;
|
|
121
133
|
esac
|
|
122
134
|
done
|
|
123
135
|
if [ -z "$oui" ]; then
|
|
124
|
-
cluster_interactif || refuse "confirmation impossible sans terminal : devzone mysql
|
|
136
|
+
cluster_interactif || refuse "confirmation impossible sans terminal : devzone mysql delete-data --yes"
|
|
125
137
|
printf 'Supprimer le namespace %s et tous ses volumes ? [o/N] ' "$NS" >&2
|
|
126
138
|
read -r reponse || reponse=""
|
|
127
139
|
case "$reponse" in
|
|
@@ -130,8 +142,8 @@ supprimer_donnees() {
|
|
|
130
142
|
esac
|
|
131
143
|
fi
|
|
132
144
|
CTX="$(cluster_lu)"
|
|
133
|
-
[ -n "$CTX" ] || refuse "aucun cluster choisi : devzone
|
|
134
|
-
installe || refuse "module inactif : devzone
|
|
145
|
+
[ -n "$CTX" ] || refuse "aucun cluster choisi : devzone enable mysql"
|
|
146
|
+
installe || refuse "module inactif : devzone enable mysql"
|
|
135
147
|
echo "▶ Suppression de MySQL et de ses volumes sur $CTX…"
|
|
136
148
|
# L'Application part d'abord (#538) : sinon Argo CD recrée le namespace
|
|
137
149
|
catalogue_argocd_delete mysql >/dev/null 2>&1 || true
|
|
@@ -152,11 +164,11 @@ etat() {
|
|
|
152
164
|
return 0
|
|
153
165
|
fi
|
|
154
166
|
if [ "$(k get statefulset mysql -o jsonpath='{.status.readyReplicas}' 2>/dev/null || true)" != 1 ]; then
|
|
155
|
-
echo "en échec sur $CTX : devzone
|
|
167
|
+
echo "en échec sur $CTX : devzone apply"
|
|
156
168
|
return 0
|
|
157
169
|
fi
|
|
158
170
|
if ! relais_actif mysql; then
|
|
159
|
-
echo "prêt sur $CTX, relais arrêté : devzone
|
|
171
|
+
echo "prêt sur $CTX, relais arrêté : devzone apply"
|
|
160
172
|
return 0
|
|
161
173
|
fi
|
|
162
174
|
echo "prêt sur $CTX : 127.0.0.1:$MYSQL_PORT, $(nombre_bases) base(s)"
|
|
@@ -167,12 +179,12 @@ creer() {
|
|
|
167
179
|
valider_projet "$projet"
|
|
168
180
|
for arg in "${@:2}"; do
|
|
169
181
|
case "$arg" in
|
|
170
|
-
--
|
|
182
|
+
--new-password) nouveau=1 ;;
|
|
171
183
|
*) refuse "argument inconnu : $arg" ;;
|
|
172
184
|
esac
|
|
173
185
|
done
|
|
174
186
|
CTX="$(contexte)"
|
|
175
|
-
installe || refuse "module inactif : devzone
|
|
187
|
+
installe || refuse "module inactif : devzone enable mysql"
|
|
176
188
|
fichier="$SECRETS/$projet.env"
|
|
177
189
|
if [ -z "$nouveau" ] && [ -s "$fichier" ]; then
|
|
178
190
|
mdp="$(sed -n 's/^MYSQL_PASSWORD=//p' "$fichier" 2>/dev/null | tail -1)"
|
|
@@ -204,25 +216,26 @@ ENV
|
|
|
204
216
|
liste() {
|
|
205
217
|
local CTX
|
|
206
218
|
CTX="$(contexte)"
|
|
207
|
-
installe || refuse "module inactif : devzone
|
|
219
|
+
installe || refuse "module inactif : devzone enable mysql"
|
|
220
|
+
# grep -v sort 1 sans base utilisateur : sous pipefail, liste reste à 0
|
|
208
221
|
mysql_admin -N -B -e "SHOW DATABASES" 2>/dev/null |
|
|
209
|
-
grep -vE '^(information_schema|mysql|performance_schema|sys)$' |
|
|
210
|
-
awk 'BEGIN { n = 0 } { printf " %-30s\n", $1; n++ } END { if (n == 0) print " (aucune base : devzone mysql
|
|
222
|
+
{ grep -vE '^(information_schema|mysql|performance_schema|sys)$' || true; } |
|
|
223
|
+
awk 'BEGIN { n = 0 } { printf " %-30s\n", $1; n++ } END { if (n == 0) print " (aucune base : devzone mysql create <projet>)" }'
|
|
211
224
|
}
|
|
212
|
-
# Supprime la base et l'utilisateur d'un projet (confirmation sans --
|
|
225
|
+
# Supprime la base et l'utilisateur d'un projet (confirmation sans --yes)
|
|
213
226
|
supprimer() {
|
|
214
227
|
local projet="${1:-}" oui="" arg reponse
|
|
215
228
|
valider_projet "$projet"
|
|
216
229
|
for arg in "${@:2}"; do
|
|
217
230
|
case "$arg" in
|
|
218
|
-
--
|
|
231
|
+
--yes) oui=1 ;;
|
|
219
232
|
*) refuse "argument inconnu : $arg" ;;
|
|
220
233
|
esac
|
|
221
234
|
done
|
|
222
235
|
CTX="$(contexte)"
|
|
223
|
-
installe || refuse "module inactif : devzone
|
|
236
|
+
installe || refuse "module inactif : devzone enable mysql"
|
|
224
237
|
if [ -z "$oui" ]; then
|
|
225
|
-
cluster_interactif || refuse "confirmation impossible sans terminal : devzone mysql
|
|
238
|
+
cluster_interactif || refuse "confirmation impossible sans terminal : devzone mysql delete $projet --yes"
|
|
226
239
|
printf 'Supprimer la base %s et son utilisateur ? [o/N] ' "$projet" >&2
|
|
227
240
|
read -r reponse || reponse=""
|
|
228
241
|
case "$reponse" in
|
|
@@ -245,17 +258,17 @@ relais() {
|
|
|
245
258
|
[ -n "$CTX" ] && installe && relais_lancer mysql "$CTX" "$NS" svc/mysql 3306:3306
|
|
246
259
|
}
|
|
247
260
|
case "${1:-}" in
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
261
|
+
install) installer ;;
|
|
262
|
+
delete-data) supprimer_donnees "${@:2}" ;;
|
|
263
|
+
status) etat ;;
|
|
264
|
+
create) creer "${@:2}" ;;
|
|
265
|
+
list) liste ;;
|
|
266
|
+
delete) supprimer "${@:2}" ;;
|
|
254
267
|
volume) mysql_volume "$NS" "${@:2}" ;;
|
|
255
|
-
|
|
256
|
-
|
|
268
|
+
relay-start) relais ;;
|
|
269
|
+
relay-stop) relais_arreter mysql ;;
|
|
257
270
|
*)
|
|
258
|
-
echo "devzone : catalogue mysql :
|
|
271
|
+
echo "devzone : catalogue mysql : create <projet> [--new-password] | list | delete <projet> [--yes] | volume [<nom>] [--delete <nom>] [--yes] | delete-data [--yes]" >&2
|
|
259
272
|
exit 1
|
|
260
273
|
;;
|
|
261
274
|
esac
|
|
@@ -34,19 +34,19 @@ mysql_volume() {
|
|
|
34
34
|
shift
|
|
35
35
|
for arg in "$@"; do
|
|
36
36
|
case "$arg" in
|
|
37
|
-
--
|
|
38
|
-
--
|
|
37
|
+
--delete) supprimer=1 ;;
|
|
38
|
+
--yes) oui=1 ;;
|
|
39
39
|
*) nom="$arg" ;;
|
|
40
40
|
esac
|
|
41
41
|
done
|
|
42
42
|
if [ -n "$supprimer" ]; then
|
|
43
|
-
[ -n "$nom" ] || refuse "volume --
|
|
43
|
+
[ -n "$nom" ] || refuse "volume --delete : nom manquant"
|
|
44
44
|
pvc="$nom"
|
|
45
45
|
[[ "$pvc" == *-mysql-0 ]] || pvc="$pvc-mysql-0"
|
|
46
46
|
monte="$(mysql_claim_monte "$ns")"
|
|
47
47
|
[ "${pvc%-mysql-0}" != "$monte" ] || refuse "volume monté, suppression refusée : $nom"
|
|
48
48
|
if [ -z "$oui" ]; then
|
|
49
|
-
cluster_interactif || refuse "confirmation impossible sans terminal : devzone mysql volume --
|
|
49
|
+
cluster_interactif || refuse "confirmation impossible sans terminal : devzone mysql volume --delete $nom --yes"
|
|
50
50
|
printf 'Supprimer le volume %s ? [o/N] ' "$pvc" >&2
|
|
51
51
|
read -r reponse || reponse=""
|
|
52
52
|
case "$reponse" in
|
|
@@ -64,7 +64,7 @@ mysql_volume() {
|
|
|
64
64
|
return 0
|
|
65
65
|
fi
|
|
66
66
|
contexte >/dev/null
|
|
67
|
-
installe || refuse "module inactif : devzone
|
|
67
|
+
installe || refuse "module inactif : devzone enable mysql"
|
|
68
68
|
claim="$nom"
|
|
69
69
|
[[ "$claim" == *-mysql-0 ]] && claim="${claim%-mysql-0}"
|
|
70
70
|
mysql_installer_claim "$ns" "$claim"
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Catalogue d'applications (#414) : une application préconfigurée par dossier
|
|
3
|
-
# .devcontainer/catalogue/<app>/ (app.conf
|
|
3
|
+
# .devcontainer/catalogue/<app>/ (app.conf ; le chart charts/devzone-<app>, #559), installée dans le
|
|
4
4
|
# cluster des services de devzone sous son namespace de app.conf ; l'état
|
|
5
5
|
# voulu est la ligne <app>=on|off de .devzone.modules.
|
|
6
|
-
# catalogue.sh
|
|
6
|
+
# catalogue.sh sync | apply | list | resume | json | remove <app>
|
|
7
7
|
set -euo pipefail
|
|
8
8
|
|
|
9
9
|
ICI="$(cd "$(dirname "$0")" && pwd)"
|
|
@@ -24,6 +24,18 @@ ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
|
|
|
24
24
|
# shellcheck source=SCRIPTDIR/catalogue/app.sh
|
|
25
25
|
# shellcheck disable=SC1091
|
|
26
26
|
. "$ICI/catalogue/app.sh"
|
|
27
|
+
# English command names are accepted (#557) : a copied script may miss the file
|
|
28
|
+
# shellcheck source=SCRIPTDIR/command-aliases.sh
|
|
29
|
+
# shellcheck disable=SC1091
|
|
30
|
+
if [ -f "$ICI/command-aliases.sh" ]; then
|
|
31
|
+
. "$ICI/command-aliases.sh"
|
|
32
|
+
fi
|
|
33
|
+
# Subcommand and options become their canonical English names ; the old
|
|
34
|
+
# French names warn on use (#557)
|
|
35
|
+
if command -v canonical_args >/dev/null 2>&1; then
|
|
36
|
+
canonical_args catalog "$@"
|
|
37
|
+
set -- "${ARGS_CANONICAL[@]+"${ARGS_CANONICAL[@]}"}"
|
|
38
|
+
fi
|
|
27
39
|
|
|
28
40
|
refuse() { echo "devzone : catalogue : $*" >&2; exit 2; }
|
|
29
41
|
|
|
@@ -98,7 +110,7 @@ app_prete() {
|
|
|
98
110
|
catalogue_synchroniser() (
|
|
99
111
|
local app entete manque="" tmp
|
|
100
112
|
[ -f "$ETAT" ] || return 0
|
|
101
|
-
entete="# Applications du catalogue : passer à on pour installer (devzone
|
|
113
|
+
entete="# Applications du catalogue : passer à on pour installer (devzone catalog)"
|
|
102
114
|
etat_verrou_prendre || return 1
|
|
103
115
|
# Le verrou est rendu à la sortie, y compris sur une erreur sous set -e
|
|
104
116
|
trap 'etat_verrou_lacher' EXIT
|
|
@@ -132,7 +144,7 @@ app_etat() {
|
|
|
132
144
|
fi
|
|
133
145
|
}
|
|
134
146
|
|
|
135
|
-
# devzone
|
|
147
|
+
# devzone catalog : nom, état (off, on installée, on en échec), description
|
|
136
148
|
catalogue_lister() {
|
|
137
149
|
local app etat etiquette
|
|
138
150
|
while IFS= read -r app; do
|
|
@@ -163,24 +175,6 @@ app_relais_arrete() {
|
|
|
163
175
|
! relais_actif "$app"
|
|
164
176
|
}
|
|
165
177
|
|
|
166
|
-
# Avertit des PVC mysql non montés par le StatefulSet (#440). Lecture des
|
|
167
|
-
# namespaces réservée à l'administrateur (#430).
|
|
168
|
-
catalogue_mysql_volumes_inutilises() {
|
|
169
|
-
local ctx ns monte pvc liste
|
|
170
|
-
ctx="$(cluster_lu)"
|
|
171
|
-
[ -n "$ctx" ] || return 0
|
|
172
|
-
ns="$(app_ns mysql)"
|
|
173
|
-
compte_admin "$ctx" get namespace "$ns" >/dev/null 2>&1 || return 0
|
|
174
|
-
monte="$(kubectl --context devzone -n "$ns" get statefulset mysql -o jsonpath='{.spec.volumeClaimTemplates[0].metadata.name}' 2>/dev/null || true)"
|
|
175
|
-
[ -n "$monte" ] || return 0
|
|
176
|
-
liste="$(kubectl --context devzone -n "$ns" get pvc -o jsonpath='{range .items[*]}{.metadata.name}{"\n"}{end}' 2>/dev/null | grep -E '\-mysql-0$' || true)"
|
|
177
|
-
while IFS= read -r pvc; do
|
|
178
|
-
[ -n "$pvc" ] || continue
|
|
179
|
-
[ "$pvc" != "${monte}-mysql-0" ] || continue
|
|
180
|
-
printf ' ⚠ volume %s non utilisé : devzone mysql volume\n' "$pvc"
|
|
181
|
-
done <<<"$liste"
|
|
182
|
-
}
|
|
183
|
-
|
|
184
178
|
# Lignes Applications du récapitulatif de devzone : ○ disponible, ✔ installée
|
|
185
179
|
# (adresse du relais), ✖ en échec, ⚠ attendue
|
|
186
180
|
catalogue_resume() {
|
|
@@ -188,11 +182,11 @@ catalogue_resume() {
|
|
|
188
182
|
while IFS= read -r app; do
|
|
189
183
|
[ -n "$app" ] || continue
|
|
190
184
|
case "$(app_etat "$app")" in
|
|
191
|
-
disponible) printf ' ○ application %-12s disponible, %s : devzone
|
|
185
|
+
disponible) printf ' ○ application %-12s disponible, %s : devzone enable %s\n' \
|
|
192
186
|
"$app" "$(app_lire "$app" description)" "$app" ;;
|
|
193
187
|
installée)
|
|
194
188
|
if app_relais_arrete "$app"; then
|
|
195
|
-
printf ' ⚠ application %-12s installée, relais arrêté : devzone
|
|
189
|
+
printf ' ⚠ application %-12s installée, relais arrêté : devzone repair\n' "$app"
|
|
196
190
|
else
|
|
197
191
|
if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
|
|
198
192
|
printf ' ✔ application %-12s installée : local access: devzone workspace ports\n' "$app"
|
|
@@ -201,15 +195,15 @@ catalogue_resume() {
|
|
|
201
195
|
"$app" "$(app_lire "$app" port)"
|
|
202
196
|
fi
|
|
203
197
|
fi ;;
|
|
204
|
-
attendue) printf ' ⚠ application %-12s attendue : devzone
|
|
205
|
-
*) printf ' ✖ application %s en échec : %s : devzone
|
|
198
|
+
attendue) printf ' ⚠ application %-12s attendue : devzone apply\n' "$app" ;;
|
|
199
|
+
*) printf ' ✖ application %s en échec : %s : devzone apply\n' \
|
|
206
200
|
"$app" "$(head -1 "$(fichier_echec "$app")")" ;;
|
|
207
201
|
esac
|
|
208
202
|
done <<<"$(catalogue_apps)"
|
|
209
|
-
|
|
203
|
+
app_mysql_volumes_inutilises 2>/dev/null || true
|
|
210
204
|
}
|
|
211
205
|
|
|
212
|
-
# Rubrique applications de devzone
|
|
206
|
+
# Rubrique applications de devzone status --json : mêmes champs que modules
|
|
213
207
|
catalogue_json() {
|
|
214
208
|
local app actif etat echec cmd json='[]'
|
|
215
209
|
while IFS= read -r app; do
|
|
@@ -218,10 +212,10 @@ catalogue_json() {
|
|
|
218
212
|
[ "$(voulu "$app")" = on ] && actif=true
|
|
219
213
|
etat="$(app_etat "$app")"
|
|
220
214
|
echec=""
|
|
221
|
-
cmd="devzone
|
|
215
|
+
cmd="devzone apply"
|
|
222
216
|
case "$etat" in
|
|
223
|
-
disponible) cmd="devzone
|
|
224
|
-
installée) cmd="devzone
|
|
217
|
+
disponible) cmd="devzone enable $app" ;;
|
|
218
|
+
installée) cmd="devzone disable $app" ;;
|
|
225
219
|
echec) echec="$(head -1 "$(fichier_echec "$app")")" ;;
|
|
226
220
|
esac
|
|
227
221
|
json="$(jq -cn --argjson avant "$json" --arg nom "$app" --argjson actif "$actif" \
|
|
@@ -234,16 +228,16 @@ catalogue_json() {
|
|
|
234
228
|
}
|
|
235
229
|
|
|
236
230
|
case "${1:-}" in
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
231
|
+
sync) catalogue_synchroniser ;;
|
|
232
|
+
apply) catalogue_appliquer ;;
|
|
233
|
+
list) catalogue_lister ;;
|
|
240
234
|
resume) catalogue_resume ;;
|
|
241
235
|
json) catalogue_json ;;
|
|
242
236
|
# Retrait d'une application : StatefulSet et service, volume gardé (#441)
|
|
243
|
-
|
|
237
|
+
remove) app_desinstaller "$2" ;;
|
|
244
238
|
-h | --help | aide) sed -n '2,6p' "$0" | sed 's/^# \{0,1\}//' ;;
|
|
245
239
|
*)
|
|
246
|
-
echo "devzone : catalogue :
|
|
240
|
+
echo "devzone : catalogue : sync | apply | list | resume | json | remove <app>" >&2
|
|
247
241
|
exit 1
|
|
248
242
|
;;
|
|
249
243
|
esac
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Helm-direct installation of a devzone service (#559, step 7): the chart
|
|
3
|
+
# charts/devzone-<svc> of the code tree is the only definition, installed with
|
|
4
|
+
# helm on the devzone context as the release <svc> in <ns>. Objects already
|
|
5
|
+
# there (kubectl apply of an earlier version, or left by Argo CD when its module
|
|
6
|
+
# went away) are adopted first: the annotations and the label helm requires, so
|
|
7
|
+
# that the release takes them over without recreating them.
|
|
8
|
+
# chart_install <svc> <ns> [key=value ...] adoption, then helm upgrade --install
|
|
9
|
+
# bash 3.2 (macOS).
|
|
10
|
+
|
|
11
|
+
# The charts are code: read from the code tree (this file is in .devcontainer/),
|
|
12
|
+
# whatever the devzone folder (RACINE, the state) is
|
|
13
|
+
CHART_CODE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
14
|
+
|
|
15
|
+
# Adopts the objects of the rendered chart that already exist in <ns>: helm
|
|
16
|
+
# refuses an object it does not own, so the release annotations and the
|
|
17
|
+
# managed-by label are written on them (no object is recreated)
|
|
18
|
+
chart_adopt() {
|
|
19
|
+
local svc="$1" ns="$2" rendu="$3" objets o
|
|
20
|
+
objets="$(kubectl --context devzone -n "$ns" get -f "$rendu" -o name --ignore-not-found 2>/dev/null || true)"
|
|
21
|
+
for o in $objets; do
|
|
22
|
+
kubectl --context devzone -n "$ns" annotate "$o" \
|
|
23
|
+
"meta.helm.sh/release-name=$svc" "meta.helm.sh/release-namespace=$ns" --overwrite >/dev/null
|
|
24
|
+
kubectl --context devzone -n "$ns" label "$o" app.kubernetes.io/managed-by=Helm --overwrite >/dev/null
|
|
25
|
+
done
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
# Installs or upgrades the release <svc> from charts/devzone-<svc>; the
|
|
29
|
+
# key=value arguments become --set options (image, port, memory, size, claim)
|
|
30
|
+
chart_install() {
|
|
31
|
+
local svc="$1" ns="$2" chart rendu arg
|
|
32
|
+
local -a sets
|
|
33
|
+
shift 2
|
|
34
|
+
chart="$CHART_CODE/charts/devzone-$svc"
|
|
35
|
+
if [ ! -f "$chart/Chart.yaml" ]; then
|
|
36
|
+
echo "✖ $svc : chart charts/devzone-$svc missing (manage/docs/reference.md#charts-de-devzone)" >&2
|
|
37
|
+
return 2
|
|
38
|
+
fi
|
|
39
|
+
sets=()
|
|
40
|
+
for arg in "$@"; do sets+=(--set "$arg"); done
|
|
41
|
+
rendu="$(mktemp)"
|
|
42
|
+
if ! helm template "$svc" "$chart" -n "$ns" ${sets[@]+"${sets[@]}"} >"$rendu"; then
|
|
43
|
+
rm -f "$rendu"
|
|
44
|
+
return 1
|
|
45
|
+
fi
|
|
46
|
+
chart_adopt "$svc" "$ns" "$rendu"
|
|
47
|
+
rm -f "$rendu"
|
|
48
|
+
helm --kube-context devzone upgrade --install "$svc" "$chart" -n "$ns" ${sets[@]+"${sets[@]}"} >/dev/null
|
|
49
|
+
}
|
package/.devcontainer/cluster.sh
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
# cluster_ecrire CTX garde le choix dans l'état
|
|
10
10
|
# cluster_est_local CTX 0 si cluster local (config, sans réseau)
|
|
11
11
|
# cluster_candidats locaux, puis kind dédié, puis distants
|
|
12
|
-
# cluster_choisir [CTX] [--
|
|
12
|
+
# cluster_choisir [CTX] [--confirm CTX]
|
|
13
13
|
# CTX validé (distant : confirmation),
|
|
14
14
|
# sinon choix gardé, sinon menu
|
|
15
15
|
# (terminal seulement), sinon défaut local
|
|
@@ -167,7 +167,7 @@ cluster_menu() {
|
|
|
167
167
|
i=$((i + 1))
|
|
168
168
|
done
|
|
169
169
|
[ -f "${DEVZONE_KUBE_HOTE:-$HOME/.kube/hote.config}" ] ||
|
|
170
|
-
echo " (clusters de l'hôte invisibles : devzone
|
|
170
|
+
echo " (clusters de l'hôte invisibles : devzone enable kubernetes)"
|
|
171
171
|
} >&2
|
|
172
172
|
printf 'Numéro [1] : ' >&2
|
|
173
173
|
read -r reponse || reponse=""
|
|
@@ -193,22 +193,22 @@ cluster_choisir() {
|
|
|
193
193
|
arg="$1"
|
|
194
194
|
shift
|
|
195
195
|
case "$arg" in
|
|
196
|
-
--
|
|
196
|
+
--confirm)
|
|
197
197
|
if [ "$#" -eq 0 ]; then
|
|
198
|
-
echo "devzone : --
|
|
198
|
+
echo "devzone : --confirm attend un contexte" >&2
|
|
199
199
|
return 2
|
|
200
200
|
fi
|
|
201
201
|
confirmer="$1"
|
|
202
202
|
shift
|
|
203
203
|
;;
|
|
204
|
-
--
|
|
204
|
+
--confirm=*) confirmer="${arg#*=}" ;;
|
|
205
205
|
-*)
|
|
206
|
-
echo "devzone : argument inconnu : $arg (cluster_choisir [CTX] [--
|
|
206
|
+
echo "devzone : argument inconnu : $arg (cluster_choisir [CTX] [--confirm CTX])" >&2
|
|
207
207
|
return 2
|
|
208
208
|
;;
|
|
209
209
|
*)
|
|
210
210
|
if [ -n "$voulu" ]; then
|
|
211
|
-
echo "devzone : argument inconnu : $arg (cluster_choisir [CTX] [--
|
|
211
|
+
echo "devzone : argument inconnu : $arg (cluster_choisir [CTX] [--confirm CTX])" >&2
|
|
212
212
|
return 2
|
|
213
213
|
fi
|
|
214
214
|
voulu="$arg"
|
|
@@ -223,13 +223,13 @@ cluster_choisir() {
|
|
|
223
223
|
echo "devzone : cluster inconnu ou injoignable : $voulu ; possibles : $(cluster_candidats | tr '\n' ' ')" >&2
|
|
224
224
|
return 2
|
|
225
225
|
fi
|
|
226
|
-
# Distant : confirmation requise. --
|
|
226
|
+
# Distant : confirmation requise. --confirm ne vaut que s'il est
|
|
227
227
|
# exactement le contexte demandé ; DEVZONE_CLUSTER_DISTANT reste
|
|
228
228
|
# accepté pour les tests et la CI.
|
|
229
229
|
if ! cluster_est_local "$voulu"; then
|
|
230
230
|
if [ -n "$confirmer" ]; then
|
|
231
231
|
if [ "$confirmer" != "$voulu" ]; then
|
|
232
|
-
echo "devzone : cluster distant refusé : $voulu (--
|
|
232
|
+
echo "devzone : cluster distant refusé : $voulu (--confirm $voulu)" >&2
|
|
233
233
|
return 2
|
|
234
234
|
fi
|
|
235
235
|
elif [ -n "${DEVZONE_CLUSTER_DISTANT:-}" ]; then
|
|
@@ -241,11 +241,11 @@ cluster_choisir() {
|
|
|
241
241
|
printf 'cluster distant : %s ; tape son nom pour confirmer : ' "$voulu" >&2
|
|
242
242
|
read -r reponse || reponse=""
|
|
243
243
|
if [ "$reponse" != "$voulu" ]; then
|
|
244
|
-
echo "devzone : cluster distant refusé : $voulu (--
|
|
244
|
+
echo "devzone : cluster distant refusé : $voulu (--confirm $voulu)" >&2
|
|
245
245
|
return 2
|
|
246
246
|
fi
|
|
247
247
|
else
|
|
248
|
-
echo "devzone : cluster distant refusé : $voulu (--
|
|
248
|
+
echo "devzone : cluster distant refusé : $voulu (--confirm $voulu)" >&2
|
|
249
249
|
return 2
|
|
250
250
|
fi
|
|
251
251
|
fi
|
|
@@ -18,7 +18,7 @@ clusters_afficher() {
|
|
|
18
18
|
done < <(kubectl config get-contexts -o name 2>/dev/null || true)
|
|
19
19
|
|
|
20
20
|
if [ "${#contextes[@]}" -eq 0 ]; then
|
|
21
|
-
echo "aucun cluster : kind create cluster, ou devzone
|
|
21
|
+
echo "aucun cluster : kind create cluster, ou devzone enable kubernetes"
|
|
22
22
|
return 0
|
|
23
23
|
fi
|
|
24
24
|
|
|
@@ -6,6 +6,10 @@
|
|
|
6
6
|
#
|
|
7
7
|
# command_canonical <name>: prints the current internal (French) name for an
|
|
8
8
|
# English name; otherwise the name unchanged (empty stays empty).
|
|
9
|
+
#
|
|
10
|
+
# Subcommands and options follow the same rule (#557): the table below gives
|
|
11
|
+
# the canonical English name of each French subcommand, per command, and the
|
|
12
|
+
# canonical English name of each French option.
|
|
9
13
|
|
|
10
14
|
command_canonical() {
|
|
11
15
|
case "${1:-}" in
|
|
@@ -30,7 +34,7 @@ command_canonical() {
|
|
|
30
34
|
migrate) echo migrer ;;
|
|
31
35
|
revert) echo revenir ;;
|
|
32
36
|
clean-docker) echo nettoyer-docker ;;
|
|
33
|
-
*)
|
|
37
|
+
*) printf '%s\n' "${1:-}" ;;
|
|
34
38
|
esac
|
|
35
39
|
}
|
|
36
40
|
|
|
@@ -59,7 +63,7 @@ command_english() {
|
|
|
59
63
|
migrer) echo migrate ;;
|
|
60
64
|
revenir) echo revert ;;
|
|
61
65
|
nettoyer-docker) echo clean-docker ;;
|
|
62
|
-
*)
|
|
66
|
+
*) printf '%s\n' "${1:-}" ;;
|
|
63
67
|
esac
|
|
64
68
|
}
|
|
65
69
|
|
|
@@ -77,3 +81,149 @@ command_deprecated_warning() {
|
|
|
77
81
|
fi
|
|
78
82
|
return 0
|
|
79
83
|
}
|
|
84
|
+
|
|
85
|
+
# subcommand_canonical <command> <word> : the canonical English name of a
|
|
86
|
+
# subcommand of a command (#557). The French names are accepted and warn on
|
|
87
|
+
# use; an unknown word is printed unchanged.
|
|
88
|
+
subcommand_canonical() {
|
|
89
|
+
local command="${1:-}" word="${2:-}"
|
|
90
|
+
case "$command" in
|
|
91
|
+
postgres | mysql)
|
|
92
|
+
case "$word" in
|
|
93
|
+
creer) echo create ;;
|
|
94
|
+
liste) echo list ;;
|
|
95
|
+
supprimer) echo delete ;;
|
|
96
|
+
supprimer-donnees) echo delete-data ;;
|
|
97
|
+
etat) echo status ;;
|
|
98
|
+
installer) echo install ;;
|
|
99
|
+
desinstaller) echo uninstall ;;
|
|
100
|
+
relais-lancer) echo relay-start ;;
|
|
101
|
+
relais-arreter) echo relay-stop ;;
|
|
102
|
+
autoriser) echo authorize ;;
|
|
103
|
+
interdire) echo forbid ;;
|
|
104
|
+
*) printf '%s\n' "$word" ;;
|
|
105
|
+
esac
|
|
106
|
+
;;
|
|
107
|
+
gitlab)
|
|
108
|
+
case "$word" in
|
|
109
|
+
migrer) echo migrate ;;
|
|
110
|
+
nouveau-mdp) echo new-password ;;
|
|
111
|
+
etat) echo status ;;
|
|
112
|
+
installer) echo install ;;
|
|
113
|
+
desinstaller) echo uninstall ;;
|
|
114
|
+
relais-lancer) echo relay-start ;;
|
|
115
|
+
relais-arreter) echo relay-stop ;;
|
|
116
|
+
relais-etat) echo relay-status ;;
|
|
117
|
+
*) printf '%s\n' "$word" ;;
|
|
118
|
+
esac
|
|
119
|
+
;;
|
|
120
|
+
argocd)
|
|
121
|
+
case "$word" in
|
|
122
|
+
etat) echo status ;;
|
|
123
|
+
installer) echo install ;;
|
|
124
|
+
desinstaller) echo uninstall ;;
|
|
125
|
+
relais-lancer) echo relay-start ;;
|
|
126
|
+
relais-arreter) echo relay-stop ;;
|
|
127
|
+
*) printf '%s\n' "$word" ;;
|
|
128
|
+
esac
|
|
129
|
+
;;
|
|
130
|
+
packages)
|
|
131
|
+
case "$word" in
|
|
132
|
+
ajouter) echo add ;;
|
|
133
|
+
retirer) echo remove ;;
|
|
134
|
+
appliquer) echo apply ;;
|
|
135
|
+
lister) echo list ;;
|
|
136
|
+
*) printf '%s\n' "$word" ;;
|
|
137
|
+
esac
|
|
138
|
+
;;
|
|
139
|
+
catalog)
|
|
140
|
+
case "$word" in
|
|
141
|
+
synchroniser) echo sync ;;
|
|
142
|
+
appliquer) echo apply ;;
|
|
143
|
+
lister) echo list ;;
|
|
144
|
+
desinstaller) echo remove ;;
|
|
145
|
+
*) printf '%s\n' "$word" ;;
|
|
146
|
+
esac
|
|
147
|
+
;;
|
|
148
|
+
port)
|
|
149
|
+
case "$word" in
|
|
150
|
+
ouvrir) echo open ;;
|
|
151
|
+
fermer) echo close ;;
|
|
152
|
+
liste) echo list ;;
|
|
153
|
+
relancer) echo restart ;;
|
|
154
|
+
exclure) echo exclude ;;
|
|
155
|
+
inclure) echo include ;;
|
|
156
|
+
*) printf '%s\n' "$word" ;;
|
|
157
|
+
esac
|
|
158
|
+
;;
|
|
159
|
+
*) printf '%s\n' "$word" ;;
|
|
160
|
+
esac
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
# option_canonical <word> : the canonical English name of an option (#557);
|
|
164
|
+
# an unknown option is printed unchanged.
|
|
165
|
+
option_canonical() {
|
|
166
|
+
case "${1:-}" in
|
|
167
|
+
--fermer) echo --close ;;
|
|
168
|
+
--supprimer) echo --delete ;;
|
|
169
|
+
--nouveau-mdp) echo --new-password ;;
|
|
170
|
+
--oui) echo --yes ;;
|
|
171
|
+
--confirmer) echo --confirm ;;
|
|
172
|
+
--contexte) echo --context ;;
|
|
173
|
+
*) printf '%s\n' "${1:-}" ;;
|
|
174
|
+
esac
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
# Deprecation warning for the old French subcommands (#557): same format and
|
|
178
|
+
# same DEVZONE_NO_DEPRECATION as command_deprecated_warning.
|
|
179
|
+
subcommand_deprecated_warning() {
|
|
180
|
+
local command="${1:-}" word="${2:-}" english
|
|
181
|
+
[ -n "$word" ] || return 0
|
|
182
|
+
english="$(subcommand_canonical "$command" "$word")"
|
|
183
|
+
[ "$english" != "$word" ] || return 0
|
|
184
|
+
if [ "${DEVZONE_NO_DEPRECATION:-}" != 1 ]; then
|
|
185
|
+
echo "devzone: \"$word\" is deprecated, use \"$english\"" >&2
|
|
186
|
+
fi
|
|
187
|
+
return 0
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
# Deprecation warning for the old French options (#557): same format and same
|
|
191
|
+
# DEVZONE_NO_DEPRECATION as command_deprecated_warning.
|
|
192
|
+
option_deprecated_warning() {
|
|
193
|
+
local word="${1:-}" english
|
|
194
|
+
[ -n "$word" ] || return 0
|
|
195
|
+
english="$(option_canonical "$word")"
|
|
196
|
+
[ "$english" != "$word" ] || return 0
|
|
197
|
+
if [ "${DEVZONE_NO_DEPRECATION:-}" != 1 ]; then
|
|
198
|
+
echo "devzone: \"$word\" is deprecated, use \"$english\"" >&2
|
|
199
|
+
fi
|
|
200
|
+
return 0
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
# canonical_args <command> <args...> : fills the global array ARGS_CANONICAL
|
|
204
|
+
# with the canonical English names of the arguments: the first word that is
|
|
205
|
+
# not an option is the subcommand, every option keeps its canonical English
|
|
206
|
+
# name. The old French names warn on use (#557).
|
|
207
|
+
canonical_args() {
|
|
208
|
+
local command="${1:-}" word canon premier=1
|
|
209
|
+
shift || true
|
|
210
|
+
ARGS_CANONICAL=()
|
|
211
|
+
for word in "$@"; do
|
|
212
|
+
case "$word" in
|
|
213
|
+
-*)
|
|
214
|
+
option_deprecated_warning "$word"
|
|
215
|
+
ARGS_CANONICAL+=("$(option_canonical "$word")")
|
|
216
|
+
;;
|
|
217
|
+
*)
|
|
218
|
+
if [ "$premier" = 1 ]; then
|
|
219
|
+
premier=0
|
|
220
|
+
canon="$(subcommand_canonical "$command" "$word")"
|
|
221
|
+
subcommand_deprecated_warning "$command" "$word"
|
|
222
|
+
word="$canon"
|
|
223
|
+
fi
|
|
224
|
+
ARGS_CANONICAL+=("$word")
|
|
225
|
+
;;
|
|
226
|
+
esac
|
|
227
|
+
done
|
|
228
|
+
return 0
|
|
229
|
+
}
|