devzone 0.39.1 → 0.40.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/agent.sh +1 -1
- package/.devcontainer/command-aliases.sh +46 -2
- package/.devcontainer/demarrage.sh +4 -4
- package/.devcontainer/devzone +4 -1
- package/.devcontainer/kube-config.sh +1 -1
- package/.devcontainer/post-create.sh +2 -2
- package/.devcontainer/versions.env +1 -1
- package/.devcontainer/workspace-init.sh +1 -1
- package/README.md +20 -1
- package/manage/devzone +31 -6
- package/manage/scripts/create-mode.sh +86 -0
- package/manage/scripts/kube-ready.sh +31 -0
- package/manage/scripts/poste.sh +5 -13
- package/manage/workspace.sh +5 -2
- package/package.json +1 -1
package/.devcontainer/agent.sh
CHANGED
|
@@ -64,7 +64,7 @@ agent_lancer() {
|
|
|
64
64
|
dossier="$(cd "$dossier" && pwd -P)"
|
|
65
65
|
consigne="$(cd "$(dirname "$consigne")" && pwd -P)/$(basename "$consigne")"
|
|
66
66
|
# Module ia requis : sans assistants, rien à diriger.
|
|
67
|
-
if ! bash "$ICI/devzone"
|
|
67
|
+
if ! bash "$ICI/devzone" is-enabled ia >/dev/null 2>&1; then
|
|
68
68
|
refuse "module ia désactivé : devzone activer ia"
|
|
69
69
|
fi
|
|
70
70
|
configurer
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# English command names for the devzone CLI (#502).
|
|
3
3
|
#
|
|
4
|
-
# Why: English command names are accepted now; the French names stay valid
|
|
5
|
-
#
|
|
4
|
+
# Why: English command names are accepted now; the French names stay valid
|
|
5
|
+
# and warn on use (#532).
|
|
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).
|
|
@@ -33,3 +33,47 @@ command_canonical() {
|
|
|
33
33
|
*) echo "${1:-}" ;;
|
|
34
34
|
esac
|
|
35
35
|
}
|
|
36
|
+
|
|
37
|
+
# English name of a French (internal) name; any other name unchanged.
|
|
38
|
+
# Mirror of command_canonical, used by the deprecation warning (#532).
|
|
39
|
+
command_english() {
|
|
40
|
+
case "${1:-}" in
|
|
41
|
+
actif) echo is-enabled ;;
|
|
42
|
+
activer) echo enable ;;
|
|
43
|
+
desactiver) echo disable ;;
|
|
44
|
+
aide) echo help ;;
|
|
45
|
+
appliquer) echo apply ;;
|
|
46
|
+
catalogue) echo catalog ;;
|
|
47
|
+
demarrer) echo start ;;
|
|
48
|
+
arreter) echo stop ;;
|
|
49
|
+
etat) echo status ;;
|
|
50
|
+
mots-de-passe) echo passwords ;;
|
|
51
|
+
paquets) echo packages ;;
|
|
52
|
+
plateforme) echo platform ;;
|
|
53
|
+
reparer) echo repair ;;
|
|
54
|
+
utiliser) echo use ;;
|
|
55
|
+
mettre-a-jour) echo update ;;
|
|
56
|
+
desinstaller) echo uninstall ;;
|
|
57
|
+
copier-vers) echo copy-to ;;
|
|
58
|
+
copier-depuis) echo copy-from ;;
|
|
59
|
+
migrer) echo migrate ;;
|
|
60
|
+
revenir) echo revert ;;
|
|
61
|
+
nettoyer-docker) echo clean-docker ;;
|
|
62
|
+
*) echo "${1:-}" ;;
|
|
63
|
+
esac
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
# Deprecation warning for the old French names (#532): called at the
|
|
67
|
+
# normalization points, with the word as typed. Writes one line on stderr
|
|
68
|
+
# for a French name of the table; silent for an English name, an unknown
|
|
69
|
+
# name and DEVZONE_NO_DEPRECATION=1. The exit code is always 0.
|
|
70
|
+
command_deprecated_warning() {
|
|
71
|
+
local word="${1:-}" english
|
|
72
|
+
[ -n "$word" ] || return 0
|
|
73
|
+
english="$(command_english "$word")"
|
|
74
|
+
[ "$english" != "$word" ] || return 0
|
|
75
|
+
if [ "${DEVZONE_NO_DEPRECATION:-}" != 1 ]; then
|
|
76
|
+
echo "devzone: \"$word\" is deprecated, use \"$english\"" >&2
|
|
77
|
+
fi
|
|
78
|
+
return 0
|
|
79
|
+
}
|
|
@@ -23,7 +23,7 @@ bash "$ICI/kube-compte.sh" jeton || echo "démarrage : jeton du compte kubernete
|
|
|
23
23
|
# Module gitlab actif : /etc/hosts est un montage Docker régénéré à chaque
|
|
24
24
|
# démarrage, gitlab.localhost doit être re-pose (ssh, glab et getent passent
|
|
25
25
|
# par le résolveur système) ; hote-poser n'échoue jamais (avertissement seul)
|
|
26
|
-
if bash "$ICI/devzone"
|
|
26
|
+
if bash "$ICI/devzone" is-enabled gitlab; then
|
|
27
27
|
bash "$ICI/gitlab/gitlab.sh" hote-poser || echo "démarrage : nom gitlab.localhost non posé (devzone reparer)"
|
|
28
28
|
# Relais TCP 8929/2224 : curl et git en HTTP passent par la boucle locale
|
|
29
29
|
# pour *.localhost, le relais doit être relancé après chaque démarrage
|
|
@@ -31,17 +31,17 @@ if bash "$ICI/devzone" actif gitlab; then
|
|
|
31
31
|
fi
|
|
32
32
|
# Module postgres actif : le relais (port-forward vers 127.0.0.1:5432) ne
|
|
33
33
|
# survit pas à l'arrêt du conteneur, relancé ici après les clusters
|
|
34
|
-
if bash "$ICI/devzone"
|
|
34
|
+
if bash "$ICI/devzone" is-enabled postgres; then
|
|
35
35
|
bash "$ICI/postgres/postgres.sh" relais-lancer || echo "démarrage : relais postgres non lancé (devzone reparer)"
|
|
36
36
|
fi
|
|
37
37
|
# Module argocd actif : relais (port-forward vers 127.0.0.1:8443), relancé
|
|
38
38
|
# après les clusters comme celui de postgres
|
|
39
|
-
if bash "$ICI/devzone"
|
|
39
|
+
if bash "$ICI/devzone" is-enabled argocd; then
|
|
40
40
|
bash "$ICI/argocd/argocd.sh" relais-lancer || echo "démarrage : relais argocd non lancé (devzone reparer)"
|
|
41
41
|
fi
|
|
42
42
|
# Module mysql actif : le relais 127.0.0.1:3306, relancé comme celui de
|
|
43
43
|
# postgres après chaque démarrage
|
|
44
|
-
if bash "$ICI/devzone"
|
|
44
|
+
if bash "$ICI/devzone" is-enabled mysql; then
|
|
45
45
|
bash "$ICI/catalogue/mysql/mysql.sh" relais-lancer || echo "démarrage : relais mysql non lancé (devzone reparer)"
|
|
46
46
|
fi
|
|
47
47
|
# Relais de ports vers le poste (#290) : l'IP du conteneur change à chaque
|
package/.devcontainer/devzone
CHANGED
|
@@ -1405,9 +1405,12 @@ if [ -f "$ICI/etat-json.sh" ]; then
|
|
|
1405
1405
|
fi
|
|
1406
1406
|
|
|
1407
1407
|
# English command name of the first argument becomes the French one (#502);
|
|
1408
|
-
# without any argument, nothing changes
|
|
1408
|
+
# without any argument, nothing changes. The old French names warn (#532).
|
|
1409
1409
|
if [ "$#" -gt 0 ]; then
|
|
1410
1410
|
canon="$(command_canonical "$1" 2>/dev/null)" || canon="$1"
|
|
1411
|
+
if command -v command_deprecated_warning >/dev/null 2>&1; then
|
|
1412
|
+
command_deprecated_warning "$1"
|
|
1413
|
+
fi
|
|
1411
1414
|
set -- "$canon" "${@:2}"
|
|
1412
1415
|
fi
|
|
1413
1416
|
|
|
@@ -15,7 +15,7 @@ ICI="$(dirname "$0")"
|
|
|
15
15
|
# shellcheck source=SCRIPTDIR/cluster.sh
|
|
16
16
|
. "$ICI/cluster.sh"
|
|
17
17
|
module=off
|
|
18
|
-
bash "$ICI/devzone"
|
|
18
|
+
bash "$ICI/devzone" is-enabled kubernetes && module=on
|
|
19
19
|
|
|
20
20
|
# DEVZONE_KUBE_SOURCE : tests fonctionnels (jamais le cluster de l'hôte)
|
|
21
21
|
SOURCE="${DEVZONE_KUBE_SOURCE:-$HOME/.kube-host/config}"
|
|
@@ -65,9 +65,9 @@ bash /workspaces/devzone/.devcontainer/kube-config.sh || echo "devzone : configu
|
|
|
65
65
|
if ! command -v docker >/dev/null 2>&1; then
|
|
66
66
|
sudo install -m 0755 /workspaces/devzone/.devcontainer/docker-sans-hote.sh /usr/local/bin/docker
|
|
67
67
|
fi
|
|
68
|
-
devzone
|
|
68
|
+
devzone apply || echo "devzone : modules incomplets (détail ci-dessus), réessayer : devzone appliquer" >&2
|
|
69
69
|
# Paquets systeme gardes (#351) : reinstallees a chaque creation ; un echec n arrete pas la creation
|
|
70
|
-
devzone
|
|
70
|
+
devzone packages appliquer || echo "devzone : paquets en echec, reessayer : devzone paquets" >&2
|
|
71
71
|
|
|
72
72
|
# Invite Kubernetes du shell (#337) : prefixe PS1, une seule fois
|
|
73
73
|
if ! grep -qF 'invite-kube.sh' "$HOME/.bashrc" 2>/dev/null; then
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
# Single source for the repowarden version used by post-create.sh and workspace-init.sh.
|
|
2
|
-
REPOWARDEN_VERSION=4.17.
|
|
2
|
+
REPOWARDEN_VERSION=4.17.2
|
|
3
3
|
|
|
4
4
|
# BuildKit client version installed in the workspace image (#514). Must match
|
|
5
5
|
# buildkit.image in charts/devzone-workspace/values.yaml.
|
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ devzone prépare un devcontainer Ubuntu lancé par Docker, avec des versions d'o
|
|
|
36
36
|
### Prérequis
|
|
37
37
|
|
|
38
38
|
- Docker Desktop (ou Docker Engine sous Linux). Pour Kubernetes (facultatif) : activer le cluster de Docker Desktop (*Settings → Kubernetes → Enable Kubernetes*).
|
|
39
|
-
- Pour le [workspace Kubernetes](manage/docs/reference.md#workspace-kubernetes)
|
|
39
|
+
- Pour le [workspace Kubernetes](manage/docs/reference.md#workspace-kubernetes), c'est le mode par défaut dès qu'un cluster répond à la création : un cluster Kubernetes 1.30 ou plus, `kubectl` et `helm` sur la machine. Docker n'est alors pas nécessaire ; il l'est pour le poste Docker, et pour lire les volumes à migrer (`devzone workspace migrate`, `devzone workspace revert` pour y retourner).
|
|
40
40
|
- Node et npm (pour `npx` ou l'installation globale).
|
|
41
41
|
- `make` (nécessaire pour `make shell` ; sous Windows sans `make`, voir le tableau « Au quotidien »).
|
|
42
42
|
|
|
@@ -92,6 +92,23 @@ devzone : état (devzone pour le réafficher)
|
|
|
92
92
|
|
|
93
93
|
Le premier lancement prend 4 à 5 min mesurées, plus le téléchargement des images de base sur une machine neuve.
|
|
94
94
|
|
|
95
|
+
### Kubernetes ou Docker à la création
|
|
96
|
+
|
|
97
|
+
À la création, le poste suit le cluster : Kubernetes s'il répond, Docker sinon.
|
|
98
|
+
|
|
99
|
+
```text
|
|
100
|
+
devzone mon-devzone
|
|
101
|
+
│
|
|
102
|
+
├─ cluster qui répond ──▶ workspace dans le cluster (Kubernetes)
|
|
103
|
+
│ make shell ouvre le pod ; pas de migration
|
|
104
|
+
│
|
|
105
|
+
└─ sinon ───────────────▶ poste Docker
|
|
106
|
+
make shell lance le conteneur ;
|
|
107
|
+
plus tard : devzone workspace migrate
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
`devzone mon-devzone --kubernetes` exige le cluster : sans lui, rien n'est créé. `devzone mon-devzone --docker` garde le poste Docker sans contrôler le cluster. Détails dans [manage/docs/reference.md](manage/docs/reference.md#création-directe-dans-le-cluster).
|
|
111
|
+
|
|
95
112
|
### Vérifier que tout fonctionne
|
|
96
113
|
|
|
97
114
|
```bash
|
|
@@ -186,6 +203,8 @@ Dans le conteneur, le récapitulatif `devzone` signale une version publiée plus
|
|
|
186
203
|
|
|
187
204
|
## Options
|
|
188
205
|
|
|
206
|
+
**Mode à la création** : `--kubernetes` (workspace dans le cluster, refusé sans cluster) ou `--docker` (poste Docker, sans contrôle du cluster). Sans option, le mode suit le cluster (voir [Kubernetes ou Docker à la création](#kubernetes-ou-docker-à-la-création)).
|
|
207
|
+
|
|
189
208
|
**Module `ia`** : active Claude Code et opencode (versions figées), avec le garde-fou repowarden qui les arrête avant de modifier `main` ou `develop` ou de commiter sans `repowarden cc` (voir [manage/docs/reference.md](manage/docs/reference.md#garde-fou-des-assistants-ia)). Pour l'activer : `devzone enable ia`. Ils sont désinstallés quand le module est désactivé, mais tes connexions restent dans leurs volumes.
|
|
190
209
|
|
|
191
210
|
**Module `kubernetes`** : active à chaque démarrage la connexion au cluster de l'hôte et l'installation de metrics-server sur les clusters locaux (pour voir le CPU et la RAM dans k9s). Pour l'activer : `devzone enable kubernetes`. Sans ce module, kubectl, helm, k9s et kind restent installés.
|
package/manage/devzone
CHANGED
|
@@ -421,9 +421,12 @@ aide() {
|
|
|
421
421
|
cat <<EOF
|
|
422
422
|
devzone $(version) : environnement de développement conteneurisé
|
|
423
423
|
|
|
424
|
-
devzone <dossier> [--gitops github|none|<url>]
|
|
425
|
-
crée un devzone dans <dossier> puis le lance
|
|
424
|
+
devzone <dossier> [--gitops github|none|<url>] [--kubernetes|--docker]
|
|
425
|
+
crée un devzone dans <dossier> puis le lance ;
|
|
426
426
|
GitOps repository for Argo CD: github, or a URL, or none
|
|
427
|
+
--kubernetes: workspace in the cluster (default when it answers;
|
|
428
|
+
fails with nothing created without one)
|
|
429
|
+
--docker: Docker workstation, no cluster check (migrate later)
|
|
427
430
|
devzone update [--oui] [--sans-reconstruire]
|
|
428
431
|
dans un dossier devzone : passe à la version du paquet
|
|
429
432
|
(sauvegarde les fichiers remplacés, propose make rebuild)
|
|
@@ -461,14 +464,21 @@ gitops_saisir() {
|
|
|
461
464
|
}
|
|
462
465
|
|
|
463
466
|
creer() {
|
|
464
|
-
local cible="$1" gitops="" expect="" arg valeur login nom instance
|
|
467
|
+
local cible="$1" gitops="" expect="" option="" arg valeur login nom instance
|
|
465
468
|
shift
|
|
466
469
|
for arg in "$@"; do
|
|
467
470
|
if [ "$expect" = gitops ]; then gitops="$arg"; expect=""; continue; fi
|
|
468
471
|
case "$arg" in
|
|
469
472
|
--gitops) expect=gitops ;;
|
|
470
473
|
--gitops=*) gitops="${arg#--gitops=}" ;;
|
|
471
|
-
|
|
474
|
+
--kubernetes | --docker)
|
|
475
|
+
if [ -n "$option" ] && [ "$option" != "${arg#--}" ]; then
|
|
476
|
+
echo "✖ --kubernetes and --docker: choose one" >&2
|
|
477
|
+
exit 1
|
|
478
|
+
fi
|
|
479
|
+
option="${arg#--}"
|
|
480
|
+
;;
|
|
481
|
+
*) echo "✖ option inconnue : $arg (devzone <dossier> [--gitops github|none|<url>] [--kubernetes|--docker])" >&2; exit 1 ;;
|
|
472
482
|
esac
|
|
473
483
|
done
|
|
474
484
|
if [ -n "$expect" ]; then
|
|
@@ -481,6 +491,11 @@ creer() {
|
|
|
481
491
|
exit 1
|
|
482
492
|
fi
|
|
483
493
|
|
|
494
|
+
# Mode before any copy: --kubernetes without a cluster creates nothing (#497)
|
|
495
|
+
# shellcheck source=SCRIPTDIR/scripts/create-mode.sh
|
|
496
|
+
. "$PAQUET/manage/scripts/create-mode.sh"
|
|
497
|
+
create_mode_choose "$option" || exit 1
|
|
498
|
+
|
|
484
499
|
if [ -z "$gitops" ]; then
|
|
485
500
|
if [ -t 0 ]; then
|
|
486
501
|
gitops="$(gitops_saisir)"
|
|
@@ -497,6 +512,7 @@ creer() {
|
|
|
497
512
|
: >"$cible/.gitignore"
|
|
498
513
|
completer_gitignore "$cible"
|
|
499
514
|
chmod +x "$cible/manage/scripts/desinstaller.sh" "$cible/manage/scripts/lancer.sh"
|
|
515
|
+
create_mode_write "$cible" "$CREATE_MODE"
|
|
500
516
|
# The GitOps repository of the new devzone (#539): github, an existing URL,
|
|
501
517
|
# or none, written in the .argocd.conf of the new devzone (conf.sh writes
|
|
502
518
|
# the header of the file when absent)
|
|
@@ -534,6 +550,12 @@ creer() {
|
|
|
534
550
|
cible="$(cd "$cible" && pwd)"
|
|
535
551
|
ecrire_manifeste "$cible"
|
|
536
552
|
echo "✔ devzone $(version) créé dans $cible"
|
|
553
|
+
# Kubernetes: the workspace goes to the cluster, no Docker check (Docker
|
|
554
|
+
# Desktop hosts the cluster, but devzone does not need it directly)
|
|
555
|
+
if [ "$CREATE_MODE" = kubernetes ]; then
|
|
556
|
+
create_mode_start "$cible" "$PAQUET/manage/workspace.sh"
|
|
557
|
+
return
|
|
558
|
+
fi
|
|
537
559
|
if [ -n "${DEVZONE_SANS_DEMARRER:-}" ]; then
|
|
538
560
|
echo "Pour le lancer : cd $cible && make up"
|
|
539
561
|
return 0
|
|
@@ -569,8 +591,8 @@ commande_du_conteneur() {
|
|
|
569
591
|
esac
|
|
570
592
|
}
|
|
571
593
|
|
|
572
|
-
# English command names are accepted, French ones unchanged (#502
|
|
573
|
-
# A copied devzone may miss the aliases file: then no normalization.
|
|
594
|
+
# English command names are accepted, French ones unchanged and warned (#502,
|
|
595
|
+
# #532). A copied devzone may miss the aliases file: then no normalization.
|
|
574
596
|
# On the host, translate only to a known host or container command; any other
|
|
575
597
|
# name stays as typed (so « devzone stop » creates ./stop, not ./arreter).
|
|
576
598
|
# shellcheck source=SCRIPTDIR/../.devcontainer/command-aliases.sh
|
|
@@ -579,6 +601,9 @@ if [ -f "$PAQUET/.devcontainer/command-aliases.sh" ]; then
|
|
|
579
601
|
. "$PAQUET/.devcontainer/command-aliases.sh"
|
|
580
602
|
if [ "$#" -gt 0 ]; then
|
|
581
603
|
canon="$(command_canonical "$1")"
|
|
604
|
+
if command -v command_deprecated_warning >/dev/null 2>&1; then
|
|
605
|
+
command_deprecated_warning "$1"
|
|
606
|
+
fi
|
|
582
607
|
case "$canon" in
|
|
583
608
|
mettre-a-jour | desinstaller | aide | workspace) set -- "$canon" "${@:2}" ;;
|
|
584
609
|
*)
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Workstation mode at creation (#497): a new devzone is Kubernetes when the
|
|
3
|
+
# cluster answers, Docker otherwise. Sourced by manage/devzone (creer):
|
|
4
|
+
# create_mode_choose runs before any file is copied (so --kubernetes without a
|
|
5
|
+
# cluster creates nothing), create_mode_write once the folder exists.
|
|
6
|
+
# Sourced only: no code at file level. Compatible with bash 3.2 (macOS).
|
|
7
|
+
# shellcheck disable=SC2034 # CREATE_MODE is read by manage/devzone (creer)
|
|
8
|
+
# shellcheck source=manage/scripts/kube-ready.sh
|
|
9
|
+
. "$(dirname "${BASH_SOURCE[0]}")/kube-ready.sh"
|
|
10
|
+
|
|
11
|
+
# Context shown to the user: devzone if declared, otherwise the current one.
|
|
12
|
+
kube_context() {
|
|
13
|
+
if kubectl config get-contexts -o name 2>/dev/null | grep -qx 'devzone'; then
|
|
14
|
+
echo devzone
|
|
15
|
+
else
|
|
16
|
+
kubectl config current-context 2>/dev/null || echo none
|
|
17
|
+
fi
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
# Chooses the mode from the option (kubernetes, docker, or empty) and sets
|
|
21
|
+
# CREATE_MODE to kubernetes or docker, with one line of notice. Returns 1,
|
|
22
|
+
# nothing set on disk, when --kubernetes is asked and the cluster does not
|
|
23
|
+
# answer.
|
|
24
|
+
create_mode_choose() {
|
|
25
|
+
local option="$1" reason
|
|
26
|
+
if [ "$option" = docker ]; then
|
|
27
|
+
CREATE_MODE=docker
|
|
28
|
+
echo "Docker workstation (--docker): later: devzone workspace migrate"
|
|
29
|
+
return 0
|
|
30
|
+
fi
|
|
31
|
+
if reason="$(kube_ready_reason)"; then
|
|
32
|
+
CREATE_MODE=kubernetes
|
|
33
|
+
echo "✔ Kubernetes ready ($(kube_context)): workspace in the cluster"
|
|
34
|
+
create_mode_existing
|
|
35
|
+
return 0
|
|
36
|
+
fi
|
|
37
|
+
if [ "$option" = kubernetes ]; then
|
|
38
|
+
echo "✖ Kubernetes not reachable: $reason. Nothing created: start the cluster, or create with --docker" >&2
|
|
39
|
+
return 1
|
|
40
|
+
fi
|
|
41
|
+
CREATE_MODE=docker
|
|
42
|
+
echo "⚠ Kubernetes not reachable: $reason. Docker workstation; later: devzone workspace migrate"
|
|
43
|
+
return 0
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
# A workspace already installed in the cluster (helm release devzone-workspace,
|
|
47
|
+
# or Argo CD Application devzone-workspace), from any folder: the new folder
|
|
48
|
+
# drives it too, and creation goes on (the start is a helm upgrade, the volumes
|
|
49
|
+
# stay). Notice only.
|
|
50
|
+
create_mode_existing() {
|
|
51
|
+
local ctx
|
|
52
|
+
ctx="$(kube_context)"
|
|
53
|
+
if helm status devzone-workspace --namespace devzone-workspace --kube-context "$ctx" >/dev/null 2>&1 ||
|
|
54
|
+
kubectl get application.argoproj.io devzone-workspace --namespace devzone-argocd --context "$ctx" >/dev/null 2>&1; then
|
|
55
|
+
echo "ℹ a devzone workspace already runs in this cluster: this folder drives it too"
|
|
56
|
+
fi
|
|
57
|
+
return 0
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
# Writes workspace=<mode> in <folder>/.devzone.modules: an earlier workspace=
|
|
61
|
+
# line is replaced, the other lines are kept.
|
|
62
|
+
create_mode_write() {
|
|
63
|
+
local folder="$1" mode="$2" f
|
|
64
|
+
f="$folder/.devzone.modules"
|
|
65
|
+
{
|
|
66
|
+
if [ -f "$f" ]; then grep -v '^workspace=' "$f" || true; fi
|
|
67
|
+
echo "workspace=$mode"
|
|
68
|
+
} >"$f.tmp" && mv "$f.tmp" "$f"
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
# Kubernetes creation: installs the workspace from the package script, run in
|
|
72
|
+
# the new folder (as devzone workspace start does). DEVZONE_WORKSPACE_SH
|
|
73
|
+
# replaces the script (tests); DEVZONE_SANS_DEMARRER only prints the command.
|
|
74
|
+
create_mode_start() {
|
|
75
|
+
local folder="$1" script="$2"
|
|
76
|
+
if [ -n "${DEVZONE_SANS_DEMARRER:-}" ]; then
|
|
77
|
+
echo "To start the workspace: cd $folder && devzone workspace start"
|
|
78
|
+
return 0
|
|
79
|
+
fi
|
|
80
|
+
echo "▶ Starting the workspace in the cluster (a few minutes the first time)…"
|
|
81
|
+
if ! (cd "$folder" && bash "${DEVZONE_WORKSPACE_SH:-$script}" start); then
|
|
82
|
+
echo "✖ Workspace not started. The folder is ready: only the start remains (cd $folder && devzone workspace start)" >&2
|
|
83
|
+
return 1
|
|
84
|
+
fi
|
|
85
|
+
echo "Next: cd $folder && make shell (the pod)"
|
|
86
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Shared check of the Kubernetes cluster (#497), sourced by poste.sh (and by
|
|
3
|
+
# create-mode.sh at creation). Sourced only: no code at file level.
|
|
4
|
+
# Compatible with bash 3.2 (macOS) and Linux.
|
|
5
|
+
|
|
6
|
+
# Returns 0 when kubectl and helm are present and the cluster answers within 5 s
|
|
7
|
+
# (context devzone if declared, otherwise the current context). Otherwise
|
|
8
|
+
# prints one short line on stdout (kubectl missing, helm missing, or
|
|
9
|
+
# cluster <context> unreachable (<server>)) and returns 1.
|
|
10
|
+
kube_ready_reason() {
|
|
11
|
+
local context server
|
|
12
|
+
command -v kubectl >/dev/null 2>&1 || {
|
|
13
|
+
echo "kubectl missing"
|
|
14
|
+
return 1
|
|
15
|
+
}
|
|
16
|
+
command -v helm >/dev/null 2>&1 || {
|
|
17
|
+
echo "helm missing"
|
|
18
|
+
return 1
|
|
19
|
+
}
|
|
20
|
+
if kubectl config get-contexts -o name 2>/dev/null | grep -qx 'devzone'; then
|
|
21
|
+
kubectl cluster-info --request-timeout=5s --context devzone >/dev/null 2>&1 && return 0
|
|
22
|
+
context=devzone
|
|
23
|
+
server="$(kubectl config view --minify --context devzone -o 'jsonpath={.clusters[0].server}' 2>/dev/null || true)"
|
|
24
|
+
else
|
|
25
|
+
kubectl cluster-info --request-timeout=5s >/dev/null 2>&1 && return 0
|
|
26
|
+
context="$(kubectl config current-context 2>/dev/null || true)"
|
|
27
|
+
server="$(kubectl config view --minify -o 'jsonpath={.clusters[0].server}' 2>/dev/null || true)"
|
|
28
|
+
fi
|
|
29
|
+
echo "cluster ${context:-none} unreachable (${server:-unknown server})"
|
|
30
|
+
return 1
|
|
31
|
+
}
|
package/manage/scripts/poste.sh
CHANGED
|
@@ -9,6 +9,10 @@
|
|
|
9
9
|
# Portable: bash 3.2 (macOS) and Linux.
|
|
10
10
|
set -uo pipefail
|
|
11
11
|
|
|
12
|
+
# kube_ready_reason: Kubernetes reachable check, shared with create-mode.sh (#497)
|
|
13
|
+
# shellcheck source=manage/scripts/kube-ready.sh
|
|
14
|
+
. "$(dirname "${BASH_SOURCE[0]}")/kube-ready.sh"
|
|
15
|
+
|
|
12
16
|
usage() {
|
|
13
17
|
echo "usage: bash manage/scripts/poste.sh up|shell|stop|rebuild|advice <folder>" >&2
|
|
14
18
|
}
|
|
@@ -37,18 +41,6 @@ folder_version() {
|
|
|
37
41
|
fi
|
|
38
42
|
}
|
|
39
43
|
|
|
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
|
-
command -v kubectl >/dev/null 2>&1 || return 1
|
|
44
|
-
command -v helm >/dev/null 2>&1 || return 1
|
|
45
|
-
if kubectl config get-contexts -o name 2>/dev/null | grep -qx 'devzone'; then
|
|
46
|
-
kubectl cluster-info --request-timeout=5s --context devzone >/dev/null 2>&1
|
|
47
|
-
else
|
|
48
|
-
kubectl cluster-info --request-timeout=5s >/dev/null 2>&1
|
|
49
|
-
fi
|
|
50
|
-
}
|
|
51
|
-
|
|
52
44
|
# Workspace command for the folder: clone script if present, otherwise the
|
|
53
45
|
# published CLI for the folder version, run from the folder.
|
|
54
46
|
workspace_cmd() {
|
|
@@ -80,7 +72,7 @@ fi
|
|
|
80
72
|
if [ "$target" = "advice" ] || [ "$target" = "conseil" ]; then
|
|
81
73
|
if [ "$(workspace_mode "$folder")" = kubernetes ]; then
|
|
82
74
|
echo "Kubernetes workspace: the new image is used on the next devzone workspace start (or make up)."
|
|
83
|
-
elif
|
|
75
|
+
elif kube_ready_reason >/dev/null; then
|
|
84
76
|
echo "Kubernetes reachable: devzone workspace migrate moves this workstation to the cluster (nothing is deleted, rollback: devzone workspace revert)."
|
|
85
77
|
fi
|
|
86
78
|
exit 0
|
package/manage/workspace.sh
CHANGED
|
@@ -191,13 +191,16 @@ copy_from() {
|
|
|
191
191
|
# shellcheck source=manage/scripts/argocd-services.sh
|
|
192
192
|
. "$HERE/scripts/argocd-services.sh"
|
|
193
193
|
|
|
194
|
-
# English command names are accepted, French ones unchanged (#502
|
|
195
|
-
# A copied devzone may miss the aliases file: then no normalization.
|
|
194
|
+
# English command names are accepted, French ones unchanged and warned (#502,
|
|
195
|
+
# #532). A copied devzone may miss the aliases file: then no normalization.
|
|
196
196
|
# shellcheck source=../.devcontainer/command-aliases.sh
|
|
197
197
|
# shellcheck disable=SC1091
|
|
198
198
|
if [ -f "$ROOT/.devcontainer/command-aliases.sh" ]; then
|
|
199
199
|
. "$ROOT/.devcontainer/command-aliases.sh"
|
|
200
200
|
if [ "$#" -gt 0 ]; then
|
|
201
|
+
if command -v command_deprecated_warning >/dev/null 2>&1; then
|
|
202
|
+
command_deprecated_warning "$1"
|
|
203
|
+
fi
|
|
201
204
|
set -- "$(command_canonical "$1")" "${@:2}"
|
|
202
205
|
fi
|
|
203
206
|
fi
|