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
|
@@ -18,7 +18,7 @@
|
|
|
18
18
|
#
|
|
19
19
|
# Sûr par construction : chemins et commandes réglables (tests : tout sous un
|
|
20
20
|
# dossier temporaire), et refus de toucher au vrai socket sans
|
|
21
|
-
# DEVZONE_RELAIS_REEL=oui, que seuls demarrage.sh et devzone
|
|
21
|
+
# DEVZONE_RELAIS_REEL=oui, que seuls demarrage.sh et devzone repair posent.
|
|
22
22
|
# Code : 0 contrôle réussi, 1 contrôle en échec (marque écrite pour le
|
|
23
23
|
# récapitulatif devzone), 2 refus de la garde. Compatible bash 3.2.
|
|
24
24
|
set -euo pipefail
|
|
@@ -49,7 +49,7 @@ if [ -n "${BATS_TEST_TMPDIR:-}" ] && [ "$SOCKET" = /var/run/docker.sock ]; then
|
|
|
49
49
|
fi
|
|
50
50
|
|
|
51
51
|
if [ "$SOCKET" = /var/run/docker.sock ] && [ "${DEVZONE_RELAIS_REEL:-}" != oui ]; then
|
|
52
|
-
echo "docker-relais : refus de toucher au vrai socket ($SOCKET) : lancer plutôt devzone
|
|
52
|
+
echo "docker-relais : refus de toucher au vrai socket ($SOCKET) : lancer plutôt devzone repair" >&2
|
|
53
53
|
exit 2
|
|
54
54
|
fi
|
|
55
55
|
|
|
@@ -7,6 +7,6 @@ cat >&2 <<'MESSAGE'
|
|
|
7
7
|
✖ Docker du poste non partagé (option docker-hote=off) : docker n'est pas disponible ici.
|
|
8
8
|
Pour lancer des conteneurs, utilise le workspace Kubernetes : devzone workspace
|
|
9
9
|
(docker et Testcontainers y parlent à kubedock, les images sont construites par BuildKit).
|
|
10
|
-
Pour partager le socket Docker de l'hôte : devzone
|
|
10
|
+
Pour partager le socket Docker de l'hôte : devzone enable docker-hote, puis make rebuild sur le poste.
|
|
11
11
|
MESSAGE
|
|
12
12
|
exit 1
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Sortie machine de devzone
|
|
2
|
+
# Sortie machine de devzone status (--json) : objet JSON stable et versionné.
|
|
3
3
|
# Sourcé par devzone : réutilise ses fonctions (valeur, description, …), ne
|
|
4
4
|
# réécrit pas etat(). Construit uniquement avec jq (échappement garanti).
|
|
5
5
|
|
|
@@ -91,7 +91,7 @@ etat_json() {
|
|
|
91
91
|
done <<<"$retards_out"
|
|
92
92
|
count="$(jq 'length' <<<"$outils_retards_json" 2>/dev/null || echo 0)"
|
|
93
93
|
if [ "$count" -gt 0 ]; then
|
|
94
|
-
outils_commande="devzone
|
|
94
|
+
outils_commande="devzone apply"
|
|
95
95
|
fi
|
|
96
96
|
else
|
|
97
97
|
outils_retards_json="null"
|
|
@@ -124,41 +124,41 @@ etat_json() {
|
|
|
124
124
|
content="$(cat "$ef" 2>/dev/null || true)"
|
|
125
125
|
echec_val="$content"
|
|
126
126
|
etat_val="en échec"
|
|
127
|
-
commande_val="devzone
|
|
127
|
+
commande_val="devzone apply"
|
|
128
128
|
elif [ "$m" = gitlab ]; then
|
|
129
|
-
if s="$(bash "$ICI/gitlab/gitlab.sh"
|
|
129
|
+
if s="$(bash "$ICI/gitlab/gitlab.sh" status 2>/dev/null)"; then
|
|
130
130
|
etat_val="$s"
|
|
131
131
|
else
|
|
132
132
|
etat_val=""
|
|
133
|
-
ajouter_erreur modules "gitlab.sh
|
|
133
|
+
ajouter_erreur modules "gitlab.sh status indisponible"
|
|
134
134
|
fi
|
|
135
135
|
elif [ "$m" = postgres ]; then
|
|
136
|
-
if s="$(bash "$ICI/postgres/postgres.sh"
|
|
136
|
+
if s="$(bash "$ICI/postgres/postgres.sh" status 2>/dev/null)"; then
|
|
137
137
|
etat_val="$s"
|
|
138
138
|
else
|
|
139
139
|
etat_val=""
|
|
140
140
|
ajouter_erreur modules "postgres.sh etat indisponible"
|
|
141
141
|
fi
|
|
142
142
|
elif [ "$m" = argocd ]; then
|
|
143
|
-
if s="$(bash "$ICI/argocd/argocd.sh"
|
|
143
|
+
if s="$(bash "$ICI/argocd/argocd.sh" status 2>/dev/null)"; then
|
|
144
144
|
etat_val="$s"
|
|
145
145
|
else
|
|
146
146
|
etat_val=""
|
|
147
|
-
ajouter_erreur modules "argocd.sh
|
|
147
|
+
ajouter_erreur modules "argocd.sh status indisponible"
|
|
148
148
|
fi
|
|
149
149
|
elif [ "$m" = mysql ]; then
|
|
150
|
-
if s="$(bash "$ICI/catalogue/mysql/mysql.sh"
|
|
150
|
+
if s="$(bash "$ICI/catalogue/mysql/mysql.sh" status 2>/dev/null)"; then
|
|
151
151
|
etat_val="$s"
|
|
152
152
|
else
|
|
153
153
|
etat_val=""
|
|
154
|
-
ajouter_erreur modules "mysql.sh
|
|
154
|
+
ajouter_erreur modules "mysql.sh status indisponible"
|
|
155
155
|
fi
|
|
156
156
|
else
|
|
157
157
|
etat_val="actif"
|
|
158
158
|
fi
|
|
159
159
|
else
|
|
160
160
|
etat_val="facultatif"
|
|
161
|
-
commande_val="devzone
|
|
161
|
+
commande_val="devzone enable $m"
|
|
162
162
|
fi
|
|
163
163
|
modules_json="$(jq -c \
|
|
164
164
|
--arg nom "$m" \
|
|
@@ -204,10 +204,10 @@ etat_json() {
|
|
|
204
204
|
esac
|
|
205
205
|
clusters_travail_raw="$travail_ctx"
|
|
206
206
|
if [ "$travail_interne" = true ]; then
|
|
207
|
-
clusters_commande="devzone
|
|
207
|
+
clusters_commande="devzone use $ctx_hote"
|
|
208
208
|
fi
|
|
209
209
|
|
|
210
|
-
if ports_out="$(bash "$ICI/ports.sh"
|
|
210
|
+
if ports_out="$(bash "$ICI/ports.sh" list --json 2>/dev/null)"; then
|
|
211
211
|
if printf '%s' "$ports_out" | jq -e . >/dev/null 2>&1; then
|
|
212
212
|
ports_json="$ports_out"
|
|
213
213
|
else
|
|
@@ -232,7 +232,7 @@ etat_json() {
|
|
|
232
232
|
relais_marque="${DEVZONE_RELAIS_MARQUE:-/tmp/devzone-relais-docker.echec}"
|
|
233
233
|
if [ -f "$relais_marque" ]; then
|
|
234
234
|
msg="$(head -1 "$relais_marque" 2>/dev/null || true)"
|
|
235
|
-
append_alerte relais_docker "$msg" "devzone
|
|
235
|
+
append_alerte relais_docker "$msg" "devzone repair"
|
|
236
236
|
fi
|
|
237
237
|
paquets_marque="${DEVZONE_PAQUETS_MARQUE:-/tmp/devzone-paquets.echec}"
|
|
238
238
|
if [ -f "$paquets_marque" ]; then
|
|
@@ -241,7 +241,7 @@ etat_json() {
|
|
|
241
241
|
[ -n "$n" ] || continue
|
|
242
242
|
paquets_noms="${paquets_noms:+$paquets_noms, }$n"
|
|
243
243
|
done < "$paquets_marque"
|
|
244
|
-
append_alerte paquets "$paquets_noms" "devzone
|
|
244
|
+
append_alerte paquets "$paquets_noms" "devzone packages"
|
|
245
245
|
fi
|
|
246
246
|
wt_out="$(worktrees_absents 2>/dev/null || true)"
|
|
247
247
|
while IFS= read -r chemin; do
|
|
@@ -252,7 +252,7 @@ etat_json() {
|
|
|
252
252
|
append_alerte cluster_distant "cluster distant : $services_cluster — services sur un cluster distant" ""
|
|
253
253
|
fi
|
|
254
254
|
if [ "$travail_interne" = true ]; then
|
|
255
|
-
append_alerte cluster_interne "cluster de travail : $travail_ctx (cluster interne de devzone)" "devzone
|
|
255
|
+
append_alerte cluster_interne "cluster de travail : $travail_ctx (cluster interne de devzone)" "devzone use $ctx_hote"
|
|
256
256
|
fi
|
|
257
257
|
|
|
258
258
|
argocd_repo="$(conf_get argocd repo)"
|
package/.devcontainer/etat.sh
CHANGED
|
@@ -102,7 +102,7 @@ etat_recouvrement_en_attente() {
|
|
|
102
102
|
[ -f "${ETAT}.recouvre" ]
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
# L'utilisateur a confirmé l'état (devzone
|
|
105
|
+
# L'utilisateur a confirmé l'état (devzone apply) : plus de garde
|
|
106
106
|
etat_recouvrement_confirmer() {
|
|
107
107
|
rm -f "${ETAT}.recouvre" 2>/dev/null || true
|
|
108
108
|
return 0
|
|
@@ -162,7 +162,7 @@ etat_reconstruire() {
|
|
|
162
162
|
fi
|
|
163
163
|
fi
|
|
164
164
|
if [ "$code" -eq 0 ] && [ "$vu" -eq 1 ] && etat_poser "$stage"; then
|
|
165
|
-
echo "devzone : état reconstruit depuis les namespaces du cluster des services : $ETAT (confirmez par devzone
|
|
165
|
+
echo "devzone : état reconstruit depuis les namespaces du cluster des services : $ETAT (confirmez par devzone apply)" >&2
|
|
166
166
|
[ -n "$cluster_hote" ] || echo "devzone : aucun contexte d'hôte ne pointe sur le cluster des services : pas de ligne cluster= dans $ETAT" >&2
|
|
167
167
|
rm -f "$stage"
|
|
168
168
|
return 0
|
|
@@ -193,7 +193,7 @@ etat_initialiser() {
|
|
|
193
193
|
fi
|
|
194
194
|
# 1. Copie de secours laissée par la dernière écriture (#417)
|
|
195
195
|
if [ -f "${ETAT}.prec" ] && etat_poser "${ETAT}.prec"; then
|
|
196
|
-
echo "devzone : état restauré depuis la copie de secours : $ETAT (confirmez par devzone
|
|
196
|
+
echo "devzone : état restauré depuis la copie de secours : $ETAT (confirmez par devzone apply)" >&2
|
|
197
197
|
etat_recouvrement_marquer
|
|
198
198
|
etat_verrou_lacher
|
|
199
199
|
return 0
|
|
@@ -214,7 +214,7 @@ etat_initialiser() {
|
|
|
214
214
|
# signalée une seule fois, à la création de l'état de cette instance ;
|
|
215
215
|
# stderr : initialiser est aussi appelé dans $(valeur …)
|
|
216
216
|
if [ -f "$HOME/.claude/.credentials.json" ] || [ -f "$HOME/.local/share/opencode/auth.json" ]; then
|
|
217
|
-
echo "devzone : connexion Claude Code/opencode partagée trouvée : devzone
|
|
217
|
+
echo "devzone : connexion Claude Code/opencode partagée trouvée : devzone enable ia pour l'utiliser ici" >&2
|
|
218
218
|
fi
|
|
219
219
|
return 0
|
|
220
220
|
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# GitLab held by Argo CD (#538): with the module argocd on and installed, the
|
|
3
|
+
# installation is the Application devzone-gitlab on the wrapper chart
|
|
4
|
+
# charts/devzone-gitlab at the revision, instead of a helm pass (chart.sh).
|
|
5
|
+
# The Rails secret is re-applied before it (installation.sh), the seed runs
|
|
6
|
+
# once GitLab answers (seed.sh); the runner token goes to the Secret
|
|
7
|
+
# gitlab-runner-secret written by the seed, out of Git.
|
|
8
|
+
# Sourced by installation.sh (through gitlab.sh). bash 3.2 (macOS).
|
|
9
|
+
# gitlab_argocd_active module argocd on, chart present, revision
|
|
10
|
+
# gitlab_release_adopter helm release of before Argo CD: its release
|
|
11
|
+
# secrets removed, the objects are adopted
|
|
12
|
+
# gitlab_application_apply the Application devzone-gitlab
|
|
13
|
+
# gitlab_application_retirer the Application removed (namespace kept)
|
|
14
|
+
|
|
15
|
+
# The catalogue side of Argo CD (module on, chart, revision, Application)
|
|
16
|
+
# shellcheck source=SCRIPTDIR/../argocd/catalogue-argocd.sh
|
|
17
|
+
# shellcheck disable=SC1091
|
|
18
|
+
. "$ICI/../argocd/catalogue-argocd.sh"
|
|
19
|
+
|
|
20
|
+
# The module argocd is on, the namespace devzone-argocd is installed, the chart
|
|
21
|
+
# is in the repository and the revision is known: a development clone (version
|
|
22
|
+
# 0.0.0) keeps the helm-direct path, like the catalogue applications
|
|
23
|
+
gitlab_argocd_active() {
|
|
24
|
+
catalogue_argocd_active gitlab
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# Argo CD takes over the objects of a helm release gitlab: the release secrets
|
|
28
|
+
# (sh.helm.release.v1.gitlab.*) go, so that helm no longer owns the objects
|
|
29
|
+
gitlab_release_adopter() {
|
|
30
|
+
kubectl --context devzone -n "$GITLAB_NS" delete secret \
|
|
31
|
+
-l owner=helm,name=gitlab --ignore-not-found >/dev/null 2>&1 || true
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# The Application on charts/devzone-gitlab at the revision, in the namespace of
|
|
35
|
+
# the instance; the internal URL of the webservice follows that namespace
|
|
36
|
+
# (chart value not templated, passed as a helm parameter, as in chart.sh)
|
|
37
|
+
gitlab_application_apply() {
|
|
38
|
+
catalogue_argocd_load
|
|
39
|
+
chart_require gitlab || return $?
|
|
40
|
+
echo "▶ Application devzone-gitlab (Argo CD, charts/devzone-gitlab at $(argocd_revision))…"
|
|
41
|
+
gitops_apply_application devzone-gitlab service "$GITLAB_NS" \
|
|
42
|
+
"$DEVZONE_REPO_URL" "$(argocd_revision)" "charts/devzone-gitlab" \
|
|
43
|
+
"gitlab-runner.gitlabUrl=http://gitlab-webservice-default.$GITLAB_NS.svc:8181" || return 1
|
|
44
|
+
# Argo CD reads Git every 3 min: an immediate refresh of the Application
|
|
45
|
+
kubectl --context devzone -n devzone-argocd annotate application.argoproj.io \
|
|
46
|
+
devzone-gitlab argocd.argoproj.io/refresh=normal --overwrite >/dev/null 2>&1 || true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
# The Application removed when GitLab is uninstalled: its resources leave with
|
|
50
|
+
# it; nothing to do when the module argocd is off or the Application is absent
|
|
51
|
+
gitlab_application_retirer() {
|
|
52
|
+
catalogue_argocd_application_exists gitlab || return 0
|
|
53
|
+
catalogue_argocd_delete gitlab
|
|
54
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# GitLab installed from the wrapper chart charts/devzone-gitlab (#538): the
|
|
3
|
+
# official gitlab 9.11.16 and gitlab-runner 0.88.2 are dependencies pinned in
|
|
4
|
+
# the chart, its values.yaml holds the values of the GitLab of devzone
|
|
5
|
+
# (under the gitlab and gitlab-runner keys). This file is the helm-direct
|
|
6
|
+
# path, the Application of Argo CD is argocd.sh. Sourced by installation.sh.
|
|
7
|
+
# gitlab_chart_depend repository HTTP gitlab added, dependency build
|
|
8
|
+
# gitlab_helm_pass <replicas> upgrade --install of the chart, runner replicas
|
|
9
|
+
# gitlab_runner_ancien_retirer release gitlab-runner of before #538 removed
|
|
10
|
+
# The runner is held back (replicas 0) on the first pass: its Secret
|
|
11
|
+
# gitlab-runner-secret is written by the seed, and a runner pod waiting for it
|
|
12
|
+
# would hold --wait until the timeout.
|
|
13
|
+
|
|
14
|
+
# The dependencies come from https://charts.gitlab.io (no OCI repository is
|
|
15
|
+
# published): the repository is added before the build, idempotent
|
|
16
|
+
gitlab_chart_depend() {
|
|
17
|
+
helm repo add gitlab https://charts.gitlab.io --force-update >/dev/null 2>&1 || true
|
|
18
|
+
helm dependency build "$RACINE/charts/devzone-gitlab" >/dev/null
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
# One helm pass of the wrapper chart. The webservice URL of the runner follows
|
|
22
|
+
# the namespace of the instance: the chart value is not templated, its default
|
|
23
|
+
# is the main instance, so it is passed here
|
|
24
|
+
gitlab_helm_pass() {
|
|
25
|
+
local replicas="$1"
|
|
26
|
+
compte_helm "$(compte_ctx)" upgrade --install gitlab "$RACINE/charts/devzone-gitlab" \
|
|
27
|
+
--namespace "$GITLAB_NS" \
|
|
28
|
+
--create-namespace \
|
|
29
|
+
--timeout "${GITLAB_ATTENTE}s" \
|
|
30
|
+
--wait \
|
|
31
|
+
--set "gitlab-runner.gitlabUrl=http://gitlab-webservice-default.$GITLAB_NS.svc:8181" \
|
|
32
|
+
--set "gitlab-runner.replicas=$replicas"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
# Release gitlab-runner of the installations before the wrapper chart (#396):
|
|
36
|
+
# its runner now comes with the chart, the release leaves without touching data
|
|
37
|
+
gitlab_runner_ancien_retirer() {
|
|
38
|
+
compte_helm "$(compte_ctx)" uninstall gitlab-runner --namespace "$GITLAB_NS" >/dev/null 2>&1 || true
|
|
39
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
2
|
# Module gitlab : GitLab de test dans le cluster des services (#396).
|
|
3
|
-
# Pour l'activer : devzone
|
|
4
|
-
# Pour le désactiver : devzone
|
|
3
|
+
# Pour l'activer : devzone enable gitlab
|
|
4
|
+
# Pour le désactiver : devzone disable gitlab
|
|
5
5
|
# set -euo pipefail pour ne rien lancer en erreur silencieuse.
|
|
6
6
|
set -euo pipefail
|
|
7
7
|
|
|
@@ -17,6 +17,18 @@ RACINE="${DEVZONE_RACINE:-$(dirname "$(dirname "$ICI")")}"
|
|
|
17
17
|
# shellcheck source=SCRIPTDIR/../isolement.sh
|
|
18
18
|
# shellcheck disable=SC1091
|
|
19
19
|
. "$ICI/../isolement.sh"
|
|
20
|
+
# English command names are accepted (#557) : a copied script may miss the file
|
|
21
|
+
# shellcheck source=SCRIPTDIR/../command-aliases.sh
|
|
22
|
+
# shellcheck disable=SC1091
|
|
23
|
+
if [ -f "$ICI/../command-aliases.sh" ]; then
|
|
24
|
+
. "$ICI/../command-aliases.sh"
|
|
25
|
+
fi
|
|
26
|
+
# Subcommand and options become their canonical English names ; the old
|
|
27
|
+
# French names warn on use (#557)
|
|
28
|
+
if command -v canonical_args >/dev/null 2>&1; then
|
|
29
|
+
canonical_args gitlab "$@"
|
|
30
|
+
set -- "${ARGS_CANONICAL[@]+"${ARGS_CANONICAL[@]}"}"
|
|
31
|
+
fi
|
|
20
32
|
|
|
21
33
|
# ---- Variables de délai (secondes) ----
|
|
22
34
|
# GITLAB_ATTENTE : attente globale d'installation (défaut 1200)
|
|
@@ -29,7 +41,7 @@ GITLAB_SECRETS_DIR="$RACINE/workspace/.gitlab"
|
|
|
29
41
|
# Vue regroupée des identifiants : un échec n'empêche jamais l'opération
|
|
30
42
|
regenerer_identifiants() {
|
|
31
43
|
password_regenerer ||
|
|
32
|
-
echo "devzone : gitlab : identifiants regroupés non mis à jour (devzone
|
|
44
|
+
echo "devzone : gitlab : identifiants regroupés non mis à jour (devzone passwords)" >&2
|
|
33
45
|
}
|
|
34
46
|
|
|
35
47
|
# ---- /etc/hosts du conteneur ----
|
|
@@ -49,173 +61,16 @@ GITLAB_HOTE_MARQUE="# devzone:gitlab"
|
|
|
49
61
|
# shellcheck source=SCRIPTDIR/installation.sh
|
|
50
62
|
# shellcheck disable=SC1091
|
|
51
63
|
. "$ICI/installation.sh"
|
|
52
|
-
|
|
53
|
-
#
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
fi
|
|
63
|
-
sleep 5
|
|
64
|
-
done
|
|
65
|
-
echo "devzone : timeout attente GitLab." >&2
|
|
66
|
-
return 1
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
# ---- seed : peupler GitLab de données de base ----
|
|
70
|
-
gitlab_seed() {
|
|
71
|
-
echo "▶ Seed de GitLab…"
|
|
72
|
-
|
|
73
|
-
mkdir -p "$GITLAB_SECRETS_DIR"
|
|
74
|
-
|
|
75
|
-
# Mot de passe root lu dans le secret gitlab-gitlab-initial-root-password
|
|
76
|
-
local mot_de_passe
|
|
77
|
-
mot_de_passe="$(kubectl --context devzone get secret -n "$GITLAB_NS" gitlab-gitlab-initial-root-password -o jsonpath='{.data.password}' 2>/dev/null | base64 -d 2>/dev/null || true)"
|
|
78
|
-
if [ -z "$mot_de_passe" ]; then
|
|
79
|
-
echo "devzone : seed GitLab : secret root (gitlab-gitlab-initial-root-password) introuvable, arrêt du seed." >&2
|
|
80
|
-
return 1
|
|
81
|
-
fi
|
|
82
|
-
printf '%s' "$mot_de_passe" > "$GITLAB_SECRETS_DIR/root-password"
|
|
83
|
-
chmod 600 "$GITLAB_SECRETS_DIR/root-password"
|
|
84
|
-
|
|
85
|
-
# Token d'accès root créé par kubectl exec dans le pod toolbox avec gitlab-rails runner
|
|
86
|
-
local toolbox_pod root_token
|
|
87
|
-
toolbox_pod="$(kubectl --context devzone get pod -n "$GITLAB_NS" -l app=toolbox -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true)"
|
|
88
|
-
if [ -z "$toolbox_pod" ]; then
|
|
89
|
-
echo "devzone : seed GitLab : pod toolbox (label app=toolbox) introuvable, arrêt du seed." >&2
|
|
90
|
-
return 1
|
|
91
|
-
fi
|
|
92
|
-
root_token="$(kubectl --context devzone exec -n "$GITLAB_NS" "$toolbox_pod" -- gitlab-rails runner 'puts User.find_by_username("root").personal_access_tokens.create(name: "devzone", scopes: ["api", "write_repository"], expires_at: 30.days.from_now).token' 2>/dev/null | tail -n 1 || true)"
|
|
93
|
-
if [ -z "$root_token" ]; then
|
|
94
|
-
echo "devzone : seed GitLab : création du jeton root (gitlab-rails runner) échouée, arrêt du seed." >&2
|
|
95
|
-
return 1
|
|
96
|
-
fi
|
|
97
|
-
printf '%s' "$root_token" > "$GITLAB_SECRETS_DIR/root-token"
|
|
98
|
-
chmod 600 "$GITLAB_SECRETS_DIR/root-token"
|
|
99
|
-
|
|
100
|
-
# Via l'API curl avec le token (jamais affiché en clair)
|
|
101
|
-
local token groupe_id
|
|
102
|
-
token="$(cat "$GITLAB_SECRETS_DIR/root-token")"
|
|
103
|
-
|
|
104
|
-
# Groupe devzone (testé avant création)
|
|
105
|
-
if ! curl -sf --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/groups/devzone" >/dev/null 2>&1; then
|
|
106
|
-
if ! curl -sf --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/groups" --data "name=devzone&path=devzone&visibility=private" >/dev/null 2>&1; then
|
|
107
|
-
echo "devzone : seed GitLab : création du groupe devzone échouée, arrêt du seed." >&2
|
|
108
|
-
return 1
|
|
109
|
-
fi
|
|
110
|
-
fi
|
|
111
|
-
groupe_id="$(curl -s --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/groups/devzone" | jq -r '.id // empty')"
|
|
112
|
-
if [ -z "$groupe_id" ]; then
|
|
113
|
-
echo "devzone : seed GitLab : lecture de l'identifiant numérique du groupe devzone échouée, arrêt du seed." >&2
|
|
114
|
-
return 1
|
|
115
|
-
fi
|
|
116
|
-
|
|
117
|
-
# Projet devzone/demo (testé avant création, namespace_id = ID numérique du groupe)
|
|
118
|
-
if ! curl -sf --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/projects/devzone%2Fdemo" >/dev/null 2>&1; then
|
|
119
|
-
if ! curl -sf --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/projects" --data "name=demo&namespace_id=$groupe_id" >/dev/null 2>&1; then
|
|
120
|
-
echo "devzone : seed GitLab : création du projet devzone/demo échouée, arrêt du seed." >&2
|
|
121
|
-
return 1
|
|
122
|
-
fi
|
|
123
|
-
fi
|
|
124
|
-
|
|
125
|
-
# Utilisateur dev (testé avant création, mot de passe généré aléatoirement) :
|
|
126
|
-
# un dev-password existant n'est réutilisé que si l'utilisateur dev existe
|
|
127
|
-
# encore (vérifié via l'API) ; sinon il est recréé avec un utilisateur nouveau.
|
|
128
|
-
local users_json devpass
|
|
129
|
-
users_json="$(curl -s --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/users?username=dev")"
|
|
130
|
-
if [ "$(jq length <<<"$users_json")" -eq 0 ]; then
|
|
131
|
-
devpass="$(openssl rand -base64 18 | tr -d '\n')"
|
|
132
|
-
if ! curl -sf --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/users" --data "email=dev@gitlab.localhost&username=dev&name=dev&skip_confirmation=true" --data-urlencode "password=$devpass" >/dev/null 2>&1; then
|
|
133
|
-
echo "devzone : seed GitLab : création de l'utilisateur dev échouée, arrêt du seed." >&2
|
|
134
|
-
return 1
|
|
135
|
-
fi
|
|
136
|
-
printf '%s' "$devpass" > "$GITLAB_SECRETS_DIR/dev-password"
|
|
137
|
-
chmod 600 "$GITLAB_SECRETS_DIR/dev-password"
|
|
138
|
-
fi
|
|
139
|
-
|
|
140
|
-
# Token de runner : vérifié via POST /api/v4/runners/verify ; un jeton valide
|
|
141
|
-
# est gardé, un jeton refusé (403/404) est recréé, GitLab injoignable arrête le seed.
|
|
142
|
-
local rt_jeton rt_code rt_token
|
|
143
|
-
if [ -f "$GITLAB_SECRETS_DIR/runner-token" ]; then
|
|
144
|
-
rt_jeton="$(cat "$GITLAB_SECRETS_DIR/runner-token")"
|
|
145
|
-
rt_code="$(curl -s -o /dev/null -w '%{http_code}' --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/runners/verify" --data "token=${rt_jeton}" || true)"
|
|
146
|
-
if [ "$rt_code" = "200" ]; then
|
|
147
|
-
echo "✔ Jeton de runner valide : gardé."
|
|
148
|
-
elif [ "$rt_code" = "403" ] || [ "$rt_code" = "404" ]; then
|
|
149
|
-
echo "devzone : jeton de runner d'une installation précédente refusé : recréé."
|
|
150
|
-
rt_token="$(curl -s --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/user/runners" --data "runner_type=instance_type" 2>/dev/null | jq -r '.token // empty' || true)"
|
|
151
|
-
if [ -z "$rt_token" ]; then
|
|
152
|
-
echo "devzone : seed GitLab : création du jeton de runner (POST /api/v4/user/runners) échouée, arrêt du seed." >&2
|
|
153
|
-
return 1
|
|
154
|
-
fi
|
|
155
|
-
printf '%s' "$rt_token" > "$GITLAB_SECRETS_DIR/runner-token"
|
|
156
|
-
chmod 600 "$GITLAB_SECRETS_DIR/runner-token"
|
|
157
|
-
else
|
|
158
|
-
echo "devzone : seed GitLab : vérification du jeton de runner impossible (code ${rt_code}), arrêt du seed." >&2
|
|
159
|
-
return 1
|
|
160
|
-
fi
|
|
161
|
-
else
|
|
162
|
-
rt_token="$(curl -s --header "PRIVATE-TOKEN: $token" --request POST "http://gitlab.localhost:8929/api/v4/user/runners" --data "runner_type=instance_type" 2>/dev/null | jq -r '.token // empty' || true)"
|
|
163
|
-
if [ -z "$rt_token" ]; then
|
|
164
|
-
echo "devzone : seed GitLab : création du jeton de runner (POST /api/v4/user/runners) échouée, arrêt du seed." >&2
|
|
165
|
-
return 1
|
|
166
|
-
fi
|
|
167
|
-
printf '%s' "$rt_token" > "$GITLAB_SECRETS_DIR/runner-token"
|
|
168
|
-
chmod 600 "$GITLAB_SECRETS_DIR/runner-token"
|
|
169
|
-
fi
|
|
170
|
-
|
|
171
|
-
# Push du contenu de demo/ dans devzone/demo (dépôt git temporaire, remote http avec le jeton dans l'URL, jamais affiché ; branche main)
|
|
172
|
-
# Le push utilise le jeton root (write_repository) : le jeton de runner ne peut pas pousser.
|
|
173
|
-
local push_token=""
|
|
174
|
-
push_token="$(cat "$GITLAB_SECRETS_DIR/root-token")"
|
|
175
|
-
if [ -z "$push_token" ]; then
|
|
176
|
-
echo "devzone : seed GitLab : jeton root introuvable, arrêt du seed." >&2
|
|
177
|
-
return 1
|
|
178
|
-
fi
|
|
179
|
-
# Déjà poussé (installation relancée) : rien à refaire
|
|
180
|
-
if curl -sf --header "PRIVATE-TOKEN: $push_token" "http://gitlab.localhost:8929/api/v4/projects/devzone%2Fdemo/repository/branches/main" >/dev/null 2>&1; then
|
|
181
|
-
echo "✔ Seed GitLab terminé (projet demo déjà poussé)."
|
|
182
|
-
regenerer_identifiants
|
|
183
|
-
return 0
|
|
184
|
-
fi
|
|
185
|
-
if [ -d "$ICI/demo" ]; then
|
|
186
|
-
local tmpdir
|
|
187
|
-
tmpdir="$(mktemp -d)"
|
|
188
|
-
cp -r "$ICI/demo/." "$tmpdir/"
|
|
189
|
-
if (
|
|
190
|
-
cd "$tmpdir"
|
|
191
|
-
# Dépôt jetable du script : les hooks git globaux (repowarden) n'ont
|
|
192
|
-
# rien à vérifier ici et refuseraient le commit
|
|
193
|
-
export GIT_CONFIG_PARAMETERS="'core.hooksPath=/dev/null'"
|
|
194
|
-
git init -q -b main
|
|
195
|
-
git add -A
|
|
196
|
-
git -c user.email=dev@gitlab.localhost -c user.name=dev commit -q -m "chore: projet de démonstration"
|
|
197
|
-
# gitlab.localhost n'est pas toujours résolu par git : adresse
|
|
198
|
-
# locale, et l'hôte attendu par l'ingress passé en en-tête
|
|
199
|
-
git remote add origin "http://oauth2:${push_token}@127.0.0.1:8929/devzone/demo.git"
|
|
200
|
-
git -c http.extraHeader="Host: gitlab.localhost" push -q -u origin main >/dev/null 2>&1
|
|
201
|
-
); then
|
|
202
|
-
# Vérifie le push : la branche main existe bien sur le projet
|
|
203
|
-
if ! curl -sf --header "PRIVATE-TOKEN: $push_token" "http://gitlab.localhost:8929/api/v4/projects/devzone%2Fdemo/repository/branches/main" >/dev/null 2>&1; then
|
|
204
|
-
echo "devzone : seed GitLab : push du projet demo sur /devzone/demo.git réussi mais branche main absente, arrêt du seed." >&2
|
|
205
|
-
rm -rf "$tmpdir"
|
|
206
|
-
return 1
|
|
207
|
-
fi
|
|
208
|
-
else
|
|
209
|
-
echo "devzone : seed GitLab : push du projet demo sur /devzone/demo.git échoué, arrêt du seed." >&2
|
|
210
|
-
rm -rf "$tmpdir"
|
|
211
|
-
return 1
|
|
212
|
-
fi
|
|
213
|
-
rm -rf "$tmpdir"
|
|
214
|
-
fi
|
|
215
|
-
|
|
216
|
-
echo "✔ Seed GitLab terminé."
|
|
217
|
-
regenerer_identifiants
|
|
218
|
-
}
|
|
64
|
+
# Chart enveloppe (helm direct, chart.sh), Argo CD (argocd.sh), seed (seed.sh) (#538)
|
|
65
|
+
# shellcheck source=SCRIPTDIR/chart.sh
|
|
66
|
+
# shellcheck disable=SC1091
|
|
67
|
+
. "$ICI/chart.sh"
|
|
68
|
+
# shellcheck source=SCRIPTDIR/argocd.sh
|
|
69
|
+
# shellcheck disable=SC1091
|
|
70
|
+
. "$ICI/argocd.sh"
|
|
71
|
+
# shellcheck source=SCRIPTDIR/seed.sh
|
|
72
|
+
# shellcheck disable=SC1091
|
|
73
|
+
. "$ICI/seed.sh"
|
|
219
74
|
|
|
220
75
|
# ---- hote-poser / hote-retirer : gitlab.localhost dans /etc/hosts ----
|
|
221
76
|
# Pourquoi : ssh (clone ssh://git@gitlab.localhost:2224/…), glab et getent
|
|
@@ -301,23 +156,23 @@ gitlab_etat() {
|
|
|
301
156
|
fi
|
|
302
157
|
echo "prêt : http://gitlab.localhost:8929, runner ${runner_status}"
|
|
303
158
|
else
|
|
304
|
-
echo "en échec : devzone
|
|
159
|
+
echo "en échec : devzone apply"
|
|
305
160
|
fi
|
|
306
161
|
return 0
|
|
307
162
|
}
|
|
308
163
|
|
|
309
164
|
# Gestion des sous-commandes
|
|
310
165
|
case "${1:-}" in
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
166
|
+
install) gitlab_installer ;;
|
|
167
|
+
uninstall) gitlab_desinstaller "${@:2}" ;;
|
|
168
|
+
migrate) shift; gitlab_migrer "$@" ;;
|
|
314
169
|
installe) gitlab_installe ;;
|
|
315
|
-
|
|
316
|
-
seed)
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
170
|
+
status) gitlab_etat ;;
|
|
171
|
+
seed) gitlab_seed_commande ;;
|
|
172
|
+
new-password) gitlab_nouveau_mdp "${@:2}" ;;
|
|
173
|
+
relay-start) gitlab_relais_lancer ;;
|
|
174
|
+
relay-stop) gitlab_relais_arreter ;;
|
|
175
|
+
relay-status) gitlab_relais_etat ;;
|
|
321
176
|
hote-poser) gitlab_hote_poser ;;
|
|
322
177
|
hote-retirer) gitlab_hote_retirer ;;
|
|
323
178
|
*) echo "devzone : commande inconnue : ${1:-} (devzone gitlab --help)" >&2
|