devzone 0.38.0 → 0.39.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.devcontainer/argocd/gitops.sh +18 -0
- package/.devcontainer/devzone +16 -1
- package/.devcontainer/etat-json.sh +5 -1
- package/README.md +6 -0
- package/manage/devzone +81 -3
- package/manage/scripts/desinstaller.sh +12 -0
- package/package.json +1 -1
|
@@ -67,6 +67,24 @@ gitops_init() {
|
|
|
67
67
|
https://github.com/*/*) ;;
|
|
68
68
|
*) echo "✖ GitHub repository URL expected (https://github.com/<owner>/<name>.git): $repo" >&2; return 2 ;;
|
|
69
69
|
esac
|
|
70
|
+
slug="${repo#https://github.com/}"
|
|
71
|
+
slug="${slug%.git}"
|
|
72
|
+
if gh auth status >/dev/null 2>&1 && ! gh repo view "$slug" --json name >/dev/null 2>&1; then
|
|
73
|
+
# The designated GitHub repository does not exist yet: create it,
|
|
74
|
+
# then write the files of a creation
|
|
75
|
+
if ! gh repo create "$slug" --private --description "GitOps repository of devzone: the Applications Argo CD holds (workspace, services, projects)" >/dev/null; then
|
|
76
|
+
echo "✖ cannot create the GitOps repository $slug" >&2
|
|
77
|
+
return 1
|
|
78
|
+
fi
|
|
79
|
+
echo "✔ GitOps repository created: https://github.com/$slug (private)"
|
|
80
|
+
gitops_repo_note "$repo"
|
|
81
|
+
gitops_put_text README.md "# devzone-argocd
|
|
82
|
+
|
|
83
|
+
GitOps repository of devzone, written by the devzone commands (never by hand): the Argo CD of devzone follows the apps/ folder, one Application per file (the workspace, the services, the projects added with argocd app add). Removing a file removes the Application and its resources.
|
|
84
|
+
" "devzone: GitOps repository"
|
|
85
|
+
gitops_put_text apps/.gitkeep "" "devzone: apps folder"
|
|
86
|
+
return 0
|
|
87
|
+
fi
|
|
70
88
|
gitops_repo_note "$repo"
|
|
71
89
|
echo "✔ GitOps repository: $repo ($ARGOCD_CONF)"
|
|
72
90
|
return 0
|
package/.devcontainer/devzone
CHANGED
|
@@ -63,6 +63,14 @@ MODULES=(ia kubernetes gitlab postgres argocd mysql)
|
|
|
63
63
|
if [ -f "$ICI/command-aliases.sh" ]; then
|
|
64
64
|
. "$ICI/command-aliases.sh"
|
|
65
65
|
fi
|
|
66
|
+
# .argocd.conf of the instance: the GitOps repository designation (#539)
|
|
67
|
+
# shellcheck source=SCRIPTDIR/argocd/conf.sh
|
|
68
|
+
# shellcheck disable=SC1091
|
|
69
|
+
# shellcheck disable=SC2034 # read by conf.sh
|
|
70
|
+
if [ -f "$ICI/argocd/conf.sh" ]; then
|
|
71
|
+
ARGOCD_CONF="$RACINE/.argocd.conf"
|
|
72
|
+
. "$ICI/argocd/conf.sh"
|
|
73
|
+
fi
|
|
66
74
|
|
|
67
75
|
# Assistants IA, versions figées : mettre à jour ici, puis devzone appliquer
|
|
68
76
|
# (ou Rebuild Container). Une ligne par paquet, séparées par une ligne qui ne
|
|
@@ -1189,7 +1197,7 @@ utiliser() {
|
|
|
1189
1197
|
# État complet : ✔ prêt, ✖ nécessaire, ○ facultatif, ⚠ à corriger ; chaque
|
|
1190
1198
|
# point à faire avec sa commande (affiché à chaque démarrage)
|
|
1191
1199
|
etat() {
|
|
1192
|
-
local nom email statut m retards chemin ports_etat relais_marque ctx_travail ctx_hote paquets_marque paquets_noms
|
|
1200
|
+
local nom email statut m retards chemin ports_etat relais_marque ctx_travail ctx_hote paquets_marque paquets_noms argocd_repo
|
|
1193
1201
|
echo "devzone : état (devzone pour le réafficher)"
|
|
1194
1202
|
ligne_version_disponible
|
|
1195
1203
|
nom="$(git config --get user.name || true)"
|
|
@@ -1258,6 +1266,13 @@ etat() {
|
|
|
1258
1266
|
printf ' ○ module %-10s facultatif, %s : devzone activer %s\n' "$m" "$(description "$m")" "$m"
|
|
1259
1267
|
fi
|
|
1260
1268
|
done
|
|
1269
|
+
# GitOps repository of the instance (#539): the designation of .argocd.conf
|
|
1270
|
+
argocd_repo="$(conf_get argocd repo)"
|
|
1271
|
+
if [ -n "$argocd_repo" ] && [ "$argocd_repo" != none ]; then
|
|
1272
|
+
printf ' ○ argocd GitOps repository: %s\n' "$argocd_repo"
|
|
1273
|
+
else
|
|
1274
|
+
printf ' ○ argocd no GitOps repository: devzone argocd init\n'
|
|
1275
|
+
fi
|
|
1261
1276
|
# Socket Docker de l'hôte (#432) : l'avertissement montre l'état réel,
|
|
1262
1277
|
# le socket monté (même variable que docker-relais.sh), pas l'option :
|
|
1263
1278
|
# le montage ne change qu'au make rebuild (faux rassurant en attendant)
|
|
@@ -28,7 +28,7 @@ etat_json() {
|
|
|
28
28
|
local id_nom="" id_email="" id_ok=false id_commande=""
|
|
29
29
|
local plat_nom plat_url="" github_json="null"
|
|
30
30
|
local outils_retards_json='[]' outils_commande=""
|
|
31
|
-
local modules_json='[]' m actif desc ef content etat_val echec_val commande_val s
|
|
31
|
+
local modules_json='[]' m actif desc ef content etat_val echec_val commande_val s argocd_repo=""
|
|
32
32
|
local docker_hote=false docker_hote_actif=false relais_source
|
|
33
33
|
local services_cluster="" services_distant=false
|
|
34
34
|
local travail_ctx="" travail_interne=false ctx_hote=""
|
|
@@ -255,6 +255,8 @@ etat_json() {
|
|
|
255
255
|
append_alerte cluster_interne "cluster de travail : $travail_ctx (cluster interne de devzone)" "devzone utiliser $ctx_hote"
|
|
256
256
|
fi
|
|
257
257
|
|
|
258
|
+
argocd_repo="$(conf_get argocd repo)"
|
|
259
|
+
|
|
258
260
|
jq -n \
|
|
259
261
|
--argjson schema 1 \
|
|
260
262
|
--arg dv "$dv_raw" \
|
|
@@ -269,6 +271,7 @@ etat_json() {
|
|
|
269
271
|
--argjson retards "$outils_retards_json" \
|
|
270
272
|
--arg outils_commande "$outils_commande" \
|
|
271
273
|
--argjson modules "$modules_json" \
|
|
274
|
+
--arg argocd_repo "$argocd_repo" \
|
|
272
275
|
--argjson docker_hote "$docker_hote" \
|
|
273
276
|
--argjson docker_hote_actif "$docker_hote_actif" \
|
|
274
277
|
--arg clusters_services "$clusters_services_raw" \
|
|
@@ -286,6 +289,7 @@ etat_json() {
|
|
|
286
289
|
devzone: { version: (if $dv=="" then null else $dv end), disponible: (if $dvp=="" then null else $dvp end) },
|
|
287
290
|
identite_git: { ok: $id_ok, nom: (if $id_nom=="" then null else $id_nom end), email: (if $id_email=="" then null else $id_email end), commande: (if $id_commande=="" then null else $id_commande end) },
|
|
288
291
|
plateforme: { nom: $plat_nom, url: (if $plat_url=="" then null else $plat_url end), github: $github },
|
|
292
|
+
argocd_repo: (if $argocd_repo == "" then null else $argocd_repo end),
|
|
289
293
|
outils: { retards: $retards, commande: (if $outils_commande=="" then null else $outils_commande end) },
|
|
290
294
|
modules: $modules,
|
|
291
295
|
docker_hote: $docker_hote,
|
package/README.md
CHANGED
|
@@ -63,6 +63,12 @@ cd mon-devzone
|
|
|
63
63
|
make shell
|
|
64
64
|
```
|
|
65
65
|
|
|
66
|
+
Avec un compte GitHub, l'option `--gitops <github|none|<url>>` renseigne le dépôt GitOps dès la création du dossier :
|
|
67
|
+
|
|
68
|
+
```bash
|
|
69
|
+
npx devzone mon-devzone --gitops github
|
|
70
|
+
```
|
|
71
|
+
|
|
66
72
|
Ou bien récupérer le code directement :
|
|
67
73
|
|
|
68
74
|
```bash
|
package/manage/devzone
CHANGED
|
@@ -421,7 +421,9 @@ aide() {
|
|
|
421
421
|
cat <<EOF
|
|
422
422
|
devzone $(version) : environnement de développement conteneurisé
|
|
423
423
|
|
|
424
|
-
devzone <dossier>
|
|
424
|
+
devzone <dossier> [--gitops github|none|<url>]
|
|
425
|
+
crée un devzone dans <dossier> puis le lance (make up) ;
|
|
426
|
+
GitOps repository for Argo CD: github, or a URL, or none
|
|
425
427
|
devzone update [--oui] [--sans-reconstruire]
|
|
426
428
|
dans un dossier devzone : passe à la version du paquet
|
|
427
429
|
(sauvegarde les fichiers remplacés, propose make rebuild)
|
|
@@ -439,12 +441,54 @@ devzone $(version) : environnement de développement conteneurisé
|
|
|
439
441
|
EOF
|
|
440
442
|
}
|
|
441
443
|
|
|
444
|
+
gitops_saisir() {
|
|
445
|
+
# GitOps repository of Argo CD for the creation (#539): github, an
|
|
446
|
+
# existing URL, or none. Asked in a terminal (default: github when gh is
|
|
447
|
+
# connected), or none with a notice without one (the --gitops option names
|
|
448
|
+
# the choice).
|
|
449
|
+
local reponse defaut=""
|
|
450
|
+
if gh auth status >/dev/null 2>&1; then
|
|
451
|
+
defaut="github"
|
|
452
|
+
fi
|
|
453
|
+
printf 'GitOps repository for Argo CD? [G]itHub (created under your gh account at first start) / a URL / [n]one : ' >&2
|
|
454
|
+
read -r reponse || reponse=""
|
|
455
|
+
reponse="${reponse:-$defaut}"
|
|
456
|
+
case "$reponse" in
|
|
457
|
+
G | g | GitHub | github | Oui | oui | OUI) echo "github" ;;
|
|
458
|
+
n | N | none | None | Non | non | NON | aucun | Aucun) echo "none" ;;
|
|
459
|
+
*) echo "$reponse" ;;
|
|
460
|
+
esac
|
|
461
|
+
}
|
|
462
|
+
|
|
442
463
|
creer() {
|
|
443
|
-
local cible="$1"
|
|
464
|
+
local cible="$1" gitops="" expect="" arg valeur login nom instance
|
|
465
|
+
shift
|
|
466
|
+
for arg in "$@"; do
|
|
467
|
+
if [ "$expect" = gitops ]; then gitops="$arg"; expect=""; continue; fi
|
|
468
|
+
case "$arg" in
|
|
469
|
+
--gitops) expect=gitops ;;
|
|
470
|
+
--gitops=*) gitops="${arg#--gitops=}" ;;
|
|
471
|
+
*) echo "✖ option inconnue : $arg (devzone <dossier> [--gitops github|none|<url>])" >&2; exit 1 ;;
|
|
472
|
+
esac
|
|
473
|
+
done
|
|
474
|
+
if [ -n "$expect" ]; then
|
|
475
|
+
echo "✖ --gitops attend une valeur (github, none or a URL)" >&2
|
|
476
|
+
exit 1
|
|
477
|
+
fi
|
|
478
|
+
|
|
444
479
|
if [ -e "$cible" ] && [ -n "$(ls -A "$cible" 2>/dev/null)" ]; then
|
|
445
480
|
echo "✖ $cible existe et n'est pas vide : rien n'est écrasé. Choisis un autre dossier." >&2
|
|
446
481
|
exit 1
|
|
447
482
|
fi
|
|
483
|
+
|
|
484
|
+
if [ -z "$gitops" ]; then
|
|
485
|
+
if [ -t 0 ]; then
|
|
486
|
+
gitops="$(gitops_saisir)"
|
|
487
|
+
else
|
|
488
|
+
echo "⚠ no GitOps repository for Argo CD: pass --gitops <github|none|https://github.com/<login>/<name>.git> to create a devzone without a terminal; using none" >&2
|
|
489
|
+
gitops="none"
|
|
490
|
+
fi
|
|
491
|
+
fi
|
|
448
492
|
mkdir -p "$cible/workspace" "$cible/manage"
|
|
449
493
|
cp -R "${FICHIERS[@]/#/$PAQUET/}" "$cible/"
|
|
450
494
|
cp -R "$PAQUET/manage/scripts" "$cible/manage/"
|
|
@@ -453,6 +497,40 @@ creer() {
|
|
|
453
497
|
: >"$cible/.gitignore"
|
|
454
498
|
completer_gitignore "$cible"
|
|
455
499
|
chmod +x "$cible/manage/scripts/desinstaller.sh" "$cible/manage/scripts/lancer.sh"
|
|
500
|
+
# The GitOps repository of the new devzone (#539): github, an existing URL,
|
|
501
|
+
# or none, written in the .argocd.conf of the new devzone (conf.sh writes
|
|
502
|
+
# the header of the file when absent)
|
|
503
|
+
. "$PAQUET/.devcontainer/argocd/conf.sh"
|
|
504
|
+
# shellcheck disable=SC2034 # read by conf.sh
|
|
505
|
+
ARGOCD_CONF="$cible/.argocd.conf"
|
|
506
|
+
if [ "$gitops" = github ]; then
|
|
507
|
+
if ! gh auth status >/dev/null 2>&1; then
|
|
508
|
+
echo "⚠ GitHub not connected (gh auth login): no GitOps repository, the Applications are applied directly; pass --gitops none" >&2
|
|
509
|
+
valeur="none"
|
|
510
|
+
else
|
|
511
|
+
login="$(gh api user --jq .login 2>/dev/null)" || login=""
|
|
512
|
+
if [ -z "$login" ]; then
|
|
513
|
+
echo "⚠ GitHub login unreadable (gh api user): no GitOps repository, the Applications are applied directly; pass --gitops none" >&2
|
|
514
|
+
valeur="none"
|
|
515
|
+
else
|
|
516
|
+
nom="${DEVZONE_GITOPS_REPO_NAME:-devzone-argocd}"
|
|
517
|
+
instance="${DEVZONE_VOLUMES:-devzone}"
|
|
518
|
+
if [ "$instance" != "devzone" ]; then
|
|
519
|
+
nom="$nom-$instance"
|
|
520
|
+
fi
|
|
521
|
+
valeur="https://github.com/$login/$nom.git"
|
|
522
|
+
fi
|
|
523
|
+
fi
|
|
524
|
+
elif [ "$gitops" = none ]; then
|
|
525
|
+
valeur="none"
|
|
526
|
+
else
|
|
527
|
+
valeur="$gitops"
|
|
528
|
+
fi
|
|
529
|
+
conf_set argocd "repo=$valeur"
|
|
530
|
+
case "$valeur" in
|
|
531
|
+
none) echo "✔ no GitOps repository: the Applications are applied directly (devzone workspace argocd init to change)" ;;
|
|
532
|
+
*) echo "✔ GitOps repository: $valeur ($cible/.argocd.conf)" ;;
|
|
533
|
+
esac
|
|
456
534
|
cible="$(cd "$cible" && pwd)"
|
|
457
535
|
ecrire_manifeste "$cible"
|
|
458
536
|
echo "✔ devzone $(version) créé dans $cible"
|
|
@@ -543,6 +621,6 @@ case "${1:-}" in
|
|
|
543
621
|
echo "✖ devzone $1 : commande du conteneur ; lance-la dans devzone (make shell), ou choisis un autre nom de dossier" >&2
|
|
544
622
|
exit 2
|
|
545
623
|
fi
|
|
546
|
-
creer "$1"
|
|
624
|
+
creer "$1" "${@:2}"
|
|
547
625
|
;;
|
|
548
626
|
esac
|
|
@@ -31,6 +31,14 @@ esac
|
|
|
31
31
|
. "$(dirname "${BASH_SOURCE[0]}")/docker.sh"
|
|
32
32
|
docker_ready "${DEVZONE_COMMANDE:-make desinstaller}" || exit 1
|
|
33
33
|
|
|
34
|
+
# .argocd.conf of the devzone folder: the GitOps repository is never removed
|
|
35
|
+
# with the devzone, only its designation can be changed later
|
|
36
|
+
# shellcheck disable=SC2034 # read by conf.sh
|
|
37
|
+
ARGOCD_CONF="$HERE/.argocd.conf"
|
|
38
|
+
# shellcheck source=SCRIPTDIR/../.devcontainer/argocd/conf.sh
|
|
39
|
+
# shellcheck disable=SC1091
|
|
40
|
+
. "$HERE/.devcontainer/argocd/conf.sh"
|
|
41
|
+
|
|
34
42
|
# Instance name: an instance name may contain a dash (my-devzone),
|
|
35
43
|
# so DEVZONE_VOLUMES is never split
|
|
36
44
|
DEVZONE_INSTANCE="${DEVZONE_VOLUMES:-devzone}"
|
|
@@ -220,4 +228,8 @@ command -v kubectl >/dev/null 2>&1 || echo " metrics-server: kubectl not on hos
|
|
|
220
228
|
echo " base image mcr.microsoft.com/devcontainers/base (shared): docker rmi mcr.microsoft.com/devcontainers/base:ubuntu-24.04"
|
|
221
229
|
echo " devcontainer CLI npx cache: ~/.npm/_npx"
|
|
222
230
|
echo " \"GitHub CLI\" authorization on your account: GitHub → Settings → Applications"
|
|
231
|
+
ARGOCD_REPO="$(conf_get argocd repo)"
|
|
232
|
+
if [ -n "$ARGOCD_REPO" ] && [ "$ARGOCD_REPO" != none ]; then
|
|
233
|
+
echo " GitOps repository not removed: $ARGOCD_REPO (delete it yourself if you want to)"
|
|
234
|
+
fi
|
|
223
235
|
echo " this folder: $HERE"
|