devzone 1.1.0 → 3.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (118) hide show
  1. package/.devcontainer/Dockerfile +4 -4
  2. package/.devcontainer/{agent-erreurs.sh → agent-errors.sh} +6 -6
  3. package/.devcontainer/agent-local.sh +2 -2
  4. package/.devcontainer/{agent-modele.messages → agent-model.messages} +1 -1
  5. package/.devcontainer/{agent-modele.sh → agent-model.sh} +5 -5
  6. package/.devcontainer/agent-pod-manifest.sh +4 -4
  7. package/.devcontainer/{agent-droits.sh → agent-rights.sh} +2 -2
  8. package/.devcontainer/agent-session.sh +3 -3
  9. package/.devcontainer/{agent-etat-json.sh → agent-state-json.sh} +6 -6
  10. package/.devcontainer/agent-workspace.sh +1 -1
  11. package/.devcontainer/agent.sh +14 -14
  12. package/.devcontainer/{ia/docker-garde.sh → ai/docker-guard.sh} +1 -1
  13. package/.devcontainer/{ia → ai}/host-models.sh +2 -2
  14. package/.devcontainer/{ia/plugins/devzone-garde-v2.js → ai/plugins/devzone-guard-v2.js} +7 -7
  15. package/.devcontainer/{ia/plugins/devzone-garde.js → ai/plugins/devzone-guard.js} +6 -6
  16. package/.devcontainer/argocd/argocd.sh +94 -93
  17. package/.devcontainer/argocd/{catalogue-argocd.sh → catalog-argocd.sh} +3 -3
  18. package/.devcontainer/argocd/services-hook.sh +8 -8
  19. package/.devcontainer/argocd/services.sh +1 -1
  20. package/.devcontainer/catalog/app.sh +209 -0
  21. package/.devcontainer/catalog/catalog-watcher.sh +130 -0
  22. package/.devcontainer/{catalogue → catalog}/mysql/app.conf +1 -1
  23. package/.devcontainer/catalog/mysql/install.sh +87 -0
  24. package/.devcontainer/catalog/mysql/mysql.sh +262 -0
  25. package/.devcontainer/catalog/mysql/volume.sh +71 -0
  26. package/.devcontainer/catalog.sh +231 -0
  27. package/.devcontainer/chart-direct.sh +1 -1
  28. package/.devcontainer/cluster.sh +222 -224
  29. package/.devcontainer/clusters.sh +41 -41
  30. package/.devcontainer/devcontainer.json +1 -1
  31. package/.devcontainer/devzone +103 -1506
  32. package/.devcontainer/devzone-ai-guard.sh +76 -0
  33. package/.devcontainer/devzone-ai.sh +201 -0
  34. package/.devcontainer/devzone-cluster.sh +210 -0
  35. package/.devcontainer/devzone-modules.sh +126 -0
  36. package/.devcontainer/devzone-platform.sh +189 -0
  37. package/.devcontainer/devzone-repair.sh +94 -0
  38. package/.devcontainer/devzone-services.sh +241 -0
  39. package/.devcontainer/devzone-skill.sh +97 -0
  40. package/.devcontainer/devzone-status.sh +140 -0
  41. package/.devcontainer/devzone-version.sh +78 -0
  42. package/.devcontainer/git-identity.sh +28 -0
  43. package/.devcontainer/gitlab/argocd.sh +2 -2
  44. package/.devcontainer/gitlab/chart.sh +2 -2
  45. package/.devcontainer/gitlab/gitlab.sh +83 -84
  46. package/.devcontainer/gitlab/installation.sh +111 -111
  47. package/.devcontainer/gitlab/secrets.sh +47 -47
  48. package/.devcontainer/gitlab/seed.sh +77 -77
  49. package/.devcontainer/gitlab/test-gitlab.sh +242 -243
  50. package/.devcontainer/help.sh +1 -1
  51. package/.devcontainer/isolation.sh +65 -0
  52. package/.devcontainer/kind-wrapper.sh +45 -0
  53. package/.devcontainer/kube-account.sh +199 -0
  54. package/.devcontainer/kube-config.sh +45 -46
  55. package/.devcontainer/{invite-kube.sh → kube-prompt.sh} +6 -6
  56. package/.devcontainer/kube-reachable.sh +64 -0
  57. package/.devcontainer/{memoire.sh → memory.sh} +1 -1
  58. package/.devcontainer/metrics-server.sh +2 -2
  59. package/.devcontainer/opencode.jsonc +2 -2
  60. package/.devcontainer/packages.sh +228 -0
  61. package/.devcontainer/password.sh +1 -1
  62. package/.devcontainer/ports-auto.sh +152 -153
  63. package/.devcontainer/ports-json.sh +16 -15
  64. package/.devcontainer/ports.sh +127 -123
  65. package/.devcontainer/post-create.sh +52 -52
  66. package/.devcontainer/postgres/postgres.sh +176 -176
  67. package/.devcontainer/rename-legacy-files.sh +103 -0
  68. package/.devcontainer/services-admin.sh +5 -5
  69. package/.devcontainer/skills/devzone/SKILL.md +40 -41
  70. package/.devcontainer/startup.sh +65 -0
  71. package/.devcontainer/{etat-gitops.sh → state-gitops.sh} +1 -1
  72. package/.devcontainer/{etat-json.sh → state-json.sh} +39 -65
  73. package/.devcontainer/{etat-verrou.sh → state-lock.sh} +1 -1
  74. package/.devcontainer/{etat.sh → state.sh} +4 -4
  75. package/.devcontainer/workspace-init.sh +17 -3
  76. package/Makefile +8 -8
  77. package/README.md +195 -194
  78. package/charts/devzone-workspace/templates/statefulset.yaml +1 -1
  79. package/manage/devzone +8 -10
  80. package/manage/scripts/argocd-workspace.sh +1 -1
  81. package/manage/scripts/check-go-layout.sh +40 -0
  82. package/manage/scripts/check-names.sh +61 -0
  83. package/manage/scripts/create-cluster.sh +1 -1
  84. package/manage/scripts/create-mode.sh +2 -2
  85. package/manage/scripts/devzone-create.sh +5 -5
  86. package/manage/scripts/devzone-manifest.sh +3 -3
  87. package/manage/scripts/devzone-update.sh +12 -8
  88. package/manage/scripts/docker-workstation.sh +2 -2
  89. package/manage/scripts/docker.sh +2 -2
  90. package/manage/scripts/{lancer.sh → launch.sh} +10 -51
  91. package/manage/scripts/{migrer-retour.sh → migrate-revert.sh} +4 -4
  92. package/manage/scripts/{migrer.sh → migrate.sh} +8 -14
  93. package/manage/scripts/ports-apps.sh +1 -1
  94. package/manage/scripts/ports-workspace.sh +7 -7
  95. package/manage/scripts/{desinstaller.sh → uninstall.sh} +8 -8
  96. package/manage/scripts/workspace-egress.sh +2 -2
  97. package/manage/scripts/workspace-update.sh +5 -2
  98. package/manage/scripts/workspace-wait.sh +2 -2
  99. package/manage/workspace.sh +4 -4
  100. package/package.json +1 -1
  101. package/.devcontainer/catalogue/app.sh +0 -211
  102. package/.devcontainer/catalogue/catalogue-veilleur.sh +0 -130
  103. package/.devcontainer/catalogue/mysql/installer.sh +0 -87
  104. package/.devcontainer/catalogue/mysql/mysql.sh +0 -262
  105. package/.devcontainer/catalogue/mysql/volume.sh +0 -71
  106. package/.devcontainer/catalogue.sh +0 -231
  107. package/.devcontainer/demarrage.sh +0 -66
  108. package/.devcontainer/docker-relais.sh +0 -149
  109. package/.devcontainer/docker-sans-hote.sh +0 -12
  110. package/.devcontainer/git-identite.sh +0 -28
  111. package/.devcontainer/isolement.sh +0 -65
  112. package/.devcontainer/kind-enveloppe.sh +0 -45
  113. package/.devcontainer/kube-compte.sh +0 -200
  114. package/.devcontainer/kube-joignable.sh +0 -64
  115. package/.devcontainer/paquets.sh +0 -227
  116. /package/.devcontainer/{ia/docker-garde.message → ai/docker-guard.message} +0 -0
  117. /package/.devcontainer/{ia → ai}/host-check.message +0 -0
  118. /package/.devcontainer/{ia → ai}/host-check.sh +0 -0
@@ -0,0 +1,140 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # devzone, status summary of the modules.
4
+ # Sourced by .devcontainer/devzone (split of the 1 600 lines file, #722):
5
+ # functions only, shared variables are defined in devzone.
6
+
7
+ # Full state: ✔ ready, ✖ required, ○ optional, ⚠ to fix; each point to do with
8
+ # its command (shown at each startup)
9
+ show_state() {
10
+ local name email status m late path ports_state ctx_work ctx_host packages_mark packages_names argocd_repo
11
+ echo "devzone: state (devzone to show it again)"
12
+ version_available_line
13
+ name="$(git config --get user.name || true)"
14
+ email="$(git config --get user.email || true)"
15
+ if [ -n "$name" ] && [ -n "$email" ]; then
16
+ echo " ✔ git identity $name <$email>"
17
+ else
18
+ echo " ✖ git identity needed to commit: gh auth login -s workflow (automatic),"
19
+ echo " or git config --file ~/.config/git/config user.name \"<name>\" and user.email \"<email>\""
20
+ fi
21
+ if [ "$(platform_read)" = gitlab ]; then
22
+ # gitlab platform: the instance and glab, then the lines specific to
23
+ # GitHub (gh checks) reported as not applicable here, pending the GitLab
24
+ # support of repowarden (#531)
25
+ platform_line
26
+ url="$(gitlab_url_read)"
27
+ if git config --global --get "credential.$url.helper" 2>/dev/null | grep -q 'glab auth git-credential'; then
28
+ echo " ✔ git via glab"
29
+ else
30
+ echo " ⚠ git via glab to set: devzone platform gitlab"
31
+ fi
32
+ echo " ○ GitHub not needed here (gitlab platform chosen)"
33
+ echo " ⚠ repowarden stays on GitHub (bots and tickets): GitLab support coming (simdevWarden/repowarden#531)"
34
+ else
35
+ platform_line
36
+ if ! status="$(gh auth status 2>&1)"; then
37
+ echo " ○ GitHub optional (push and PR, repowarden tickets) : gh auth login -s workflow"
38
+ elif grep -q "Token scopes:" <<<"$status" && ! grep -q "'workflow'" <<<"$status"; then
39
+ echo " ⚠ GitHub connected, without workflow permission (push of .github/workflows/ refused): gh auth refresh -h github.com -s workflow"
40
+ else
41
+ echo " ✔ GitHub connected"
42
+ fi
43
+ fi
44
+ if late="$(outdated_tools)"; then
45
+ if [ -z "$late" ]; then
46
+ echo " ✔ tools pinned versions"
47
+ else
48
+ while read -r package pinned installed; do
49
+ [ -n "$package" ] || continue
50
+ echo " ⚠ tools $package $installed installed, $pinned pinned: devzone apply"
51
+ done <<<"$late"
52
+ fi
53
+ fi
54
+ while IFS= read -r path; do
55
+ [ -n "$path" ] || continue
56
+ echo " ⚠ worktree $path absent here (created outside the container?): manage it on that side, never git worktree prune here (manage/docs/reference.md, Git worktrees)"
57
+ done < <(missing_worktrees)
58
+ for m in "${MODULES[@]}"; do
59
+ if in_pod && service_module "$m"; then
60
+ # Kubernetes workspace pod (#528): presence by the cluster DNS
61
+ service_pod_line "$m"
62
+ elif [ "$(value_of "$m")" = on ] && [ -f "$(failure_marker_file "$m")" ]; then
63
+ printf ' ✖ module %-10s failed: incomplete install (%s): devzone apply\n' "$m" "$(cat "$(failure_marker_file "$m")")"
64
+ elif [ "$(value_of "$m")" = on ] && [ "$m" = gitlab ]; then
65
+ # gitlab active: its real state (ready, runner, failed)
66
+ printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/gitlab/gitlab.sh" status)"
67
+ elif [ "$(value_of "$m")" = on ] && [ "$m" = postgres ]; then
68
+ printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/$m/$m.sh" status)"
69
+ elif [ "$(value_of "$m")" = on ] && [ "$m" = argocd ]; then
70
+ printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/argocd/argocd.sh" status)"
71
+ elif [ "$(value_of "$m")" = on ] && [ "$m" = mysql ]; then
72
+ printf ' ✔ module %-10s %s\n' "$m" "$(bash "$ICI/catalog/mysql/mysql.sh" status)"
73
+ elif [ "$(value_of "$m")" = on ]; then
74
+ printf ' ✔ module %-10s active: %s\n' "$m" "$(description "$m")"
75
+ else
76
+ printf ' ○ module %-10s optional, %s: devzone enable %s\n' "$m" "$(description "$m")" "$m"
77
+ fi
78
+ done
79
+ # GitOps repository of the instance (#539): the designation of .argocd.conf
80
+ argocd_repo="$(conf_get argocd repo)"
81
+ if [ -n "$argocd_repo" ] && [ "$argocd_repo" != none ]; then
82
+ printf ' ○ argocd GitOps repository: %s\n' "$argocd_repo"
83
+ elif in_pod; then
84
+ gitops_state_line
85
+ else
86
+ printf ' ○ argocd no GitOps repository: devzone argocd init\n'
87
+ fi
88
+ # Catalog applications (#414)
89
+ if [ -d "$ICI/catalog" ]; then
90
+ bash "$ICI/catalog.sh" resume
91
+ fi
92
+ # GitLab Rails secret (#347): warning if the secrets were lost
93
+ if [ "$(value_of gitlab)" = on ] && [ ! -f "$RACINE/workspace/.gitlab/rails-secret.yaml" ]; then
94
+ echo " ⚠ gitlab GitLab reinstalled: if the browser shows 422, delete the site data of gitlab.localhost"
95
+ fi
96
+ # Remote devzone cluster: warning in the summary
97
+ current_cluster="$(cluster_saved)"
98
+ if [ -n "$current_cluster" ] && ! cluster_is_local "$current_cluster"; then
99
+ printf ' ⚠ cluster remote: %s — services on a remote cluster\n' "$current_cluster"
100
+ fi
101
+ # Old kind-gitlab cluster still present: invite to migrate (#396)
102
+ if kind get clusters 2>/dev/null | grep -qx "gitlab${INSTANCE_SUFFIX}"; then
103
+ printf ' ⚠ old kind-gitlab cluster%s: devzone gitlab migrate\n' "$INSTANCE_SUFFIX"
104
+ fi
105
+ # Internal working cluster (kind): warning in the summary
106
+ ctx_work="$(kubectl config current-context 2>/dev/null || true)"
107
+ case "$ctx_work" in
108
+ kind-gitlab* | kind-devzone*)
109
+ ctx_host="$(KUBECONFIG="${DEVZONE_KUBE_HOST:-$HOME/.kube/hote.config}" kubectl config current-context 2>/dev/null || true)"
110
+ if [ -n "$ctx_host" ] && cluster_reachable "$ctx_host"; then
111
+ printf ' ⚠ working cluster: %s (devzone internal cluster); go back: devzone use %s\n' "$ctx_work" "$ctx_host"
112
+ fi
113
+ ;;
114
+ esac
115
+ # RBAC check: access check to the PostgreSQL secrets
116
+ ctx_rbac="$(kubectl auth can-i --as=system:serviceaccount:default:default get secrets -n devzone-postgres 2>/dev/null || true)"
117
+ if [ "$ctx_rbac" = "yes" ]; then
118
+ printf ' ⚠ rbac : access to devzone-postgres secrets not restricted\n'
119
+ fi
120
+ ports_state="$(bash "$ICI/ports.sh" resume 2>/dev/null || true)"
121
+ case "$ports_state" in
122
+ none*) printf ' ○ ports to the workstation %s\n' "$ports_state" ;;
123
+ *) printf ' ✔ ports to the workstation %s\n' "$ports_state" ;;
124
+ esac
125
+ # Grouped credentials (#332): the path only, never the content
126
+ if [ -f "$RACINE/.password" ]; then
127
+ printf ' ○ credentials: %s\n' "$RACINE/.password"
128
+ fi
129
+ # Mark set by packages.sh at the failed reapplication (351): names of the packages not installed
130
+ packages_mark="${DEVZONE_PACKAGES_MARKER:-/tmp/devzone-packages.failed}"
131
+ if [ -f "$packages_mark" ]; then
132
+ packages_names=""
133
+ while IFS= read -r n; do
134
+ if [ -n "$n" ]; then
135
+ packages_names="${packages_names:+$packages_names, }$n"
136
+ fi
137
+ done < "$packages_mark"
138
+ echo " ⚠ packages $packages_names: devzone packages"
139
+ fi
140
+ }
@@ -0,0 +1,78 @@
1
+ #!/usr/bin/env bash
2
+ # shellcheck shell=bash
3
+ # devzone, version of the folder and of the published release.
4
+ # Sourced by .devcontainer/devzone (split of the 1 600 lines file, #722):
5
+ # functions only, shared variables are defined in devzone.
6
+
7
+ # Version of the devzone folder (manifest written by the workstation CLI),
8
+ # nothing if the folder predates the manifest
9
+ folder_version() {
10
+ local v
11
+ [ -f "$RACINE/.devzone.version" ] || return 1
12
+ v="$(sed -n '1s/^version //p' "$RACINE/.devzone.version" 2>/dev/null | head -1 || true)"
13
+ [ -n "$v" ] || return 1
14
+ printf '%s\n' "$v"
15
+ }
16
+
17
+ # True if the first version is newer than the second
18
+ version_is_newer() {
19
+ awk -v a="$1" -v b="$2" 'BEGIN {
20
+ na = split(a, x, ".")
21
+ nb = split(b, y, ".")
22
+ n = (na > nb ? na : nb)
23
+ for (i = 1; i <= n; i++) {
24
+ p = (i <= na ? x[i] : 0) + 0
25
+ q = (i <= nb ? y[i] : 0) + 0
26
+ if (p > q) exit 0
27
+ if (p < q) exit 1
28
+ }
29
+ exit 1
30
+ }'
31
+ }
32
+
33
+ # Version published on npm, at most once a day, cached under
34
+ # ~/.cache/devzone/; 5 s at most, silent offline
35
+ published_version() {
36
+ local cache day npm v tmp pid waited
37
+ cache="$HOME/.cache/devzone/version-publiee"
38
+ day="$(date +%Y-%m-%d)"
39
+ if [ -f "$cache" ] && [ "$(sed -n '1p' "$cache" 2>/dev/null || true)" = "$day" ]; then
40
+ sed -n '2p' "$cache" 2>/dev/null || true
41
+ return 0
42
+ fi
43
+ npm="${DEVZONE_NPM:-npm}"
44
+ v=""
45
+ if command -v "$npm" >/dev/null 2>&1; then
46
+ mkdir -p "$(dirname "$cache")" 2>/dev/null || true
47
+ tmp="$cache.$$"
48
+ "$npm" view devzone version >"$tmp" 2>/dev/null &
49
+ pid=$!
50
+ waited=0
51
+ while kill -0 "$pid" 2>/dev/null; do
52
+ sleep 1
53
+ waited=$((waited + 1))
54
+ if [ "$waited" -ge 5 ]; then
55
+ kill "$pid" 2>/dev/null || true
56
+ break
57
+ fi
58
+ done
59
+ wait "$pid" 2>/dev/null || true
60
+ v="$(sed -n '1p' "$tmp" 2>/dev/null | tr -d '[:space:]' || true)"
61
+ rm -f "$tmp"
62
+ fi
63
+ mkdir -p "$(dirname "$cache")" 2>/dev/null || true
64
+ printf '%s\n%s\n' "$day" "$v" >"$cache" 2>/dev/null || true
65
+ [ -n "$v" ] && printf '%s\n' "$v"
66
+ return 0
67
+ }
68
+
69
+ version_available_line() {
70
+ local folder published
71
+ folder="$(folder_version)" || return 0
72
+ published="$(published_version)" || return 0
73
+ published="${published#v}"
74
+ [ -n "$published" ] || return 0
75
+ if version_is_newer "$published" "$folder"; then
76
+ printf ' ○ devzone %s available: on the workstation, devzone update\n' "$published"
77
+ fi
78
+ }
@@ -0,0 +1,28 @@
1
+ #!/usr/bin/env bash
2
+ # Git identity, at each startup as long as it is missing: deduced from the gh
3
+ # account (specific to each user, connection kept in their volume) and written
4
+ # into ~/.config/git/config (devzone-git volume, survives rebuilds).
5
+ # An identity already set (by hand, or copied by VS Code into ~/.gitconfig) is
6
+ # never replaced. GitHub noreply email: commits are attached to the account
7
+ # without exposing the personal email.
8
+ set -euo pipefail
9
+
10
+ CONFIG="$HOME/.config/git/config"
11
+ name_git="$(git config --get user.name || true)"
12
+ email_git="$(git config --get user.email || true)"
13
+
14
+ [ -n "$name_git" ] && [ -n "$email_git" ] && exit 0
15
+
16
+ # Without gh: nothing to deduce; the devzone summary reports it
17
+ gh auth status >/dev/null 2>&1 || exit 0
18
+
19
+ id="" login="" name=""
20
+ IFS=$'\t' read -r id login name < <(gh api user --jq '[.id, .login, (.name // "")] | @tsv' 2>/dev/null || true)
21
+ if [ -z "$id" ] || [ -z "$login" ]; then
22
+ echo "git-identity : GitHub account unreadable (network?); run again: bash .devcontainer/git-identity.sh"
23
+ exit 0
24
+ fi
25
+
26
+ [ -n "$name_git" ] || git config --file "$CONFIG" user.name "${name:-$login}"
27
+ [ -n "$email_git" ] || git config --file "$CONFIG" user.email "${id}+${login}@users.noreply.github.com"
28
+ echo "git-identity : $(git config --get user.name) <$(git config --get user.email)>"
@@ -13,9 +13,9 @@
13
13
  # gitlab_application_retirer the Application removed (namespace kept)
14
14
 
15
15
  # The catalogue side of Argo CD (module on, chart, revision, Application)
16
- # shellcheck source=SCRIPTDIR/../argocd/catalogue-argocd.sh
16
+ # shellcheck source=SCRIPTDIR/../argocd/catalog-argocd.sh
17
17
  # shellcheck disable=SC1091
18
- . "$ICI/../argocd/catalogue-argocd.sh"
18
+ . "$ICI/../argocd/catalog-argocd.sh"
19
19
 
20
20
  # The module argocd is on, the namespace devzone-argocd is installed, the chart
21
21
  # is in the repository and the revision is known: a development clone (version
@@ -23,7 +23,7 @@ gitlab_chart_depend() {
23
23
  # is the main instance, so it is passed here
24
24
  gitlab_helm_pass() {
25
25
  local replicas="$1"
26
- compte_helm "$(compte_ctx)" upgrade --install gitlab "$RACINE/charts/devzone-gitlab" \
26
+ account_helm "$(account_context)" upgrade --install gitlab "$RACINE/charts/devzone-gitlab" \
27
27
  --namespace "$GITLAB_NS" \
28
28
  --create-namespace \
29
29
  --timeout "${GITLAB_ATTENTE}s" \
@@ -35,5 +35,5 @@ gitlab_helm_pass() {
35
35
  # Release gitlab-runner of the installations before the wrapper chart (#396):
36
36
  # its runner now comes with the chart, the release leaves without touching data
37
37
  gitlab_runner_ancien_retirer() {
38
- compte_helm "$(compte_ctx)" uninstall gitlab-runner --namespace "$GITLAB_NS" >/dev/null 2>&1 || true
38
+ account_helm "$(account_context)" uninstall gitlab-runner --namespace "$GITLAB_NS" >/dev/null 2>&1 || true
39
39
  }
@@ -1,55 +1,55 @@
1
1
  #!/usr/bin/env bash
2
- # Module gitlab : GitLab de test dans le cluster des services (#396).
3
- # Pour l'activer : devzone enable gitlab
4
- # Pour le désactiver : devzone disable gitlab
5
- # set -euo pipefail pour ne rien lancer en erreur silencieuse.
2
+ # GitLab module: test GitLab in the services cluster (#396).
3
+ # To enable it: devzone enable gitlab
4
+ # To disable it: devzone disable gitlab
5
+ # set -euo pipefail so that nothing fails silently.
6
6
  set -euo pipefail
7
7
 
8
- # Racine du dépôt devzone (deux niveaux au-dessus du module) ; DEVZONE_RACINE pour les tests
8
+ # Root of the devzone repository (two levels above the module); DEVZONE_ROOT for the tests
9
9
  ICI="$(cd "$(dirname "$0")" && pwd)"
10
- RACINE="${DEVZONE_RACINE:-$(dirname "$(dirname "$ICI")")}"
10
+ RACINE="${DEVZONE_ROOT:-$(dirname "$(dirname "$ICI")")}"
11
11
  # shellcheck source=SCRIPTDIR/../cluster.sh
12
12
  . "$ICI/../cluster.sh"
13
13
  # shellcheck source=SCRIPTDIR/../password.sh
14
14
  # shellcheck disable=SC1091
15
15
  . "$ICI/../password.sh"
16
- # Isolation réseau : namespace_isoler, posée avec le namespace devzone-gitlab
17
- # shellcheck source=SCRIPTDIR/../isolement.sh
16
+ # Network isolation: namespace_isolate, set with the devzone-gitlab namespace
17
+ # shellcheck source=SCRIPTDIR/../isolation.sh
18
18
  # shellcheck disable=SC1091
19
- . "$ICI/../isolement.sh"
19
+ . "$ICI/../isolation.sh"
20
20
 
21
- # ---- Variables de délai (secondes) ----
22
- # GITLAB_ATTENTE : attente globale d'installation (défaut 1200)
21
+ # ---- Delay variables (seconds) ----
22
+ # GITLAB_ATTENTE: global wait for the installation (default 1200)
23
23
  GITLAB_ATTENTE="${GITLAB_ATTENTE:-1200}"
24
24
 
25
- # ---- Chemins secrets ----
26
- # Secrets stockés dans $RACINE/workspace/.gitlab/ (chmod 600), jamais affichés.
25
+ # ---- Secret paths ----
26
+ # Secrets stored in $RACINE/workspace/.gitlab/ (chmod 600), never shown.
27
27
  GITLAB_SECRETS_DIR="$RACINE/workspace/.gitlab"
28
28
 
29
- # Vue regroupée des identifiants : un échec n'empêche jamais l'opération
29
+ # Grouped view of the credentials: a failure never prevents the operation
30
30
  regenerer_identifiants() {
31
31
  password_regenerate ||
32
- echo "devzone : gitlab : identifiants regroupés non mis à jour (devzone passwords)" >&2
32
+ echo "devzone : gitlab : grouped credentials not updated (devzone passwords)" >&2
33
33
  }
34
34
 
35
- # ---- /etc/hosts du conteneur ----
36
- # DEVZONE_HOSTS pour les tests (jamais le /etc/hosts réel)
35
+ # ---- /etc/hosts of the container ----
36
+ # DEVZONE_HOSTS for the tests (never the real /etc/hosts)
37
37
  HOSTS="${DEVZONE_HOSTS:-/etc/hosts}"
38
- GITLAB_HOTE_MARQUE="# devzone:gitlab"
38
+ GITLAB_HOST_MARK="# devzone:gitlab"
39
39
 
40
- # Secret Rails GitLab (#347) : conservation dans workspace/.gitlab, réapplication
41
- # avant helm upgrade --install et mot de passe régénérable
40
+ # GitLab Rails secret (#347): kept in workspace/.gitlab, applied again
41
+ # before helm upgrade --install, and the password can be regenerated
42
42
  # shellcheck source=SCRIPTDIR/secrets.sh
43
43
  # shellcheck disable=SC1091
44
44
  . "$ICI/secrets.sh"
45
45
 
46
- # ---- Installation, migration et relais du cluster des services ----
47
- # Nouvelle logique hors de ce fichier (#396) : namespace devzone-gitlab,
48
- # mémoire allouable, Helm contexte devzone, migration depuis kind-gitlab.
46
+ # ---- Installation, migration and relay of the services cluster ----
47
+ # New logic outside this file (#396): devzone-gitlab namespace,
48
+ # allocatable memory, Helm with the devzone context, migration from kind-gitlab.
49
49
  # shellcheck source=SCRIPTDIR/installation.sh
50
50
  # shellcheck disable=SC1091
51
51
  . "$ICI/installation.sh"
52
- # Chart enveloppe (helm direct, chart.sh), Argo CD (argocd.sh), seed (seed.sh) (#538)
52
+ # Wrapper chart (direct helm, chart.sh), Argo CD (argocd.sh), seed (seed.sh) (#538)
53
53
  # shellcheck source=SCRIPTDIR/chart.sh
54
54
  # shellcheck disable=SC1091
55
55
  . "$ICI/chart.sh"
@@ -60,110 +60,109 @@ GITLAB_HOTE_MARQUE="# devzone:gitlab"
60
60
  # shellcheck disable=SC1091
61
61
  . "$ICI/seed.sh"
62
62
 
63
- # ---- hote-poser / hote-retirer : gitlab.localhost dans /etc/hosts ----
64
- # Pourquoi : ssh (clone ssh://git@gitlab.localhost:2224/…), glab et getent
65
- # passent par le résolveur système. curl et git (libcurl) ignorent /etc/hosts
66
- # pour les noms *.localhost (RFC 6761) et passent par le relais TCP ci-dessus,
67
- # qui écoute sur 127.0.0.1. Le nom pointe donc vers 127.0.0.1 pour que ssh et
68
- # glab empruntent le même chemin. /etc/hosts est un montage Docker que Docker
69
- # régénère au démarrage du conteneur, d'où le re-pose à chaque démarrage
70
- # (demarrage.sh) et à chaque activation. Jamais de sed -i ni de mv : le
71
- # montage ne peut pas être renommé (écriture en place seulement) ; directe si
72
- # le fichier est inscriptible, sinon sudo -n. Un échec n'échoue jamais :
73
- # avertissement sur stderr et code 0, pour ne pas faire échouer l'installation
74
- # pour un nom d'hôte.
75
- gitlab_hote_poser() {
76
- local ligne tmp
77
- ligne="$(printf '127.0.0.1\tgitlab.localhost %s' "$GITLAB_HOTE_MARQUE")"
78
- # Déjà la bonne ligne, une seule fois : rien (idempotent)
79
- if [ "$(grep -c "$GITLAB_HOTE_MARQUE" "$HOSTS" 2>/dev/null || true)" = 1 ] &&
80
- grep -qxF "$ligne" "$HOSTS" 2>/dev/null; then
63
+ # ---- host-set / host-remove: gitlab.localhost in /etc/hosts ----
64
+ # Why: ssh (clone ssh://git@gitlab.localhost:2224/…), glab and getent go through
65
+ # the system resolver. curl and git (libcurl) ignore /etc/hosts for the
66
+ # *.localhost names (RFC 6761) and go through the TCP relay above, which
67
+ # listens on 127.0.0.1. The name therefore points to 127.0.0.1 so that ssh and
68
+ # glab take the same path. /etc/hosts is a Docker mount that Docker regenerates
69
+ # when the container starts, hence the set again at each start (startup.sh) and
70
+ # at each activation. Never sed -i nor mv: the mount cannot be renamed (in-place
71
+ # write only); direct if the file is writable, otherwise sudo -n. A failure never
72
+ # fails: a warning on stderr and exit code 0, so that the installation does not
73
+ # fail for a host name.
74
+ gitlab_host_set() {
75
+ local line tmp
76
+ line="$(printf '127.0.0.1\tgitlab.localhost %s' "$GITLAB_HOST_MARK")"
77
+ # Already the right line, once: nothing (idempotent)
78
+ if [ "$(grep -c "$GITLAB_HOST_MARK" "$HOSTS" 2>/dev/null || true)" = 1 ] &&
79
+ grep -qxF "$line" "$HOSTS" 2>/dev/null; then
81
80
  return 0
82
81
  fi
83
- if grep -q "$GITLAB_HOTE_MARQUE" "$HOSTS" 2>/dev/null; then
84
- # Ligne marquée avec une autre adresse (IPv6 de #320) ou doublon :
85
- # on la remplace par la bonne, en gardant le reste du fichier.
82
+ if grep -q "$GITLAB_HOST_MARK" "$HOSTS" 2>/dev/null; then
83
+ # Line marked with another address (IPv6 of #320) or duplicate:
84
+ # it is replaced by the right one, keeping the rest of the file.
86
85
  tmp="$(mktemp)"
87
- grep -v "$GITLAB_HOTE_MARQUE" "$HOSTS" >"$tmp" 2>/dev/null || true
88
- printf '%s\n' "$ligne" >>"$tmp"
86
+ grep -v "$GITLAB_HOST_MARK" "$HOSTS" >"$tmp" 2>/dev/null || true
87
+ printf '%s\n' "$line" >>"$tmp"
89
88
  if [ -w "$HOSTS" ]; then
90
89
  cp "$tmp" "$HOSTS" 2>/dev/null ||
91
- echo "devzone : gitlab : nom gitlab.localhost non posé dans $HOSTS (droits d'écriture insuffisants)" >&2
90
+ echo "devzone : gitlab : gitlab.localhost name not set in $HOSTS (insufficient write rights)" >&2
92
91
  elif ! sudo -n cp "$tmp" "$HOSTS" >/dev/null 2>&1; then
93
- echo "devzone : gitlab : nom gitlab.localhost non posé dans $HOSTS (sudo -n indisponible ou refusé)" >&2
92
+ echo "devzone : gitlab : gitlab.localhost name not set in $HOSTS (sudo -n unavailable or refused)" >&2
94
93
  fi
95
94
  rm -f "$tmp"
96
95
  return 0
97
96
  fi
98
97
  if [ -w "$HOSTS" ]; then
99
- printf '%s\n' "$ligne" >>"$HOSTS" 2>/dev/null ||
100
- echo "devzone : gitlab : nom gitlab.localhost non posé dans $HOSTS (droits d'écriture insuffisants)" >&2
101
- elif ! printf '%s\n' "$ligne" | sudo -n tee -a "$HOSTS" >/dev/null 2>&1; then
102
- echo "devzone : gitlab : nom gitlab.localhost non posé dans $HOSTS (sudo -n indisponible ou refusé)" >&2
98
+ printf '%s\n' "$line" >>"$HOSTS" 2>/dev/null ||
99
+ echo "devzone : gitlab : gitlab.localhost name not set in $HOSTS (insufficient write rights)" >&2
100
+ elif ! printf '%s\n' "$line" | sudo -n tee -a "$HOSTS" >/dev/null 2>&1; then
101
+ echo "devzone : gitlab : gitlab.localhost name not set in $HOSTS (sudo -n unavailable or refused)" >&2
103
102
  fi
104
103
  return 0
105
104
  }
106
105
 
107
- gitlab_hote_retirer() {
108
- # Aucune ligne repérée : rien (y compris fichier illisible)
109
- if ! grep -q "$GITLAB_HOTE_MARQUE" "$HOSTS" 2>/dev/null; then
106
+ gitlab_host_remove() {
107
+ # No line found: nothing (including an unreadable file)
108
+ if ! grep -q "$GITLAB_HOST_MARK" "$HOSTS" 2>/dev/null; then
110
109
  return 0
111
110
  fi
112
111
  local tmp
113
112
  tmp="$(mktemp)"
114
- grep -v "$GITLAB_HOTE_MARQUE" "$HOSTS" >"$tmp" 2>/dev/null || true
113
+ grep -v "$GITLAB_HOST_MARK" "$HOSTS" >"$tmp" 2>/dev/null || true
115
114
  if [ -w "$HOSTS" ]; then
116
115
  cp "$tmp" "$HOSTS" 2>/dev/null ||
117
- echo "devzone : gitlab : ligne gitlab.localhost non retirée de $HOSTS (droits d'écriture insuffisants)" >&2
116
+ echo "devzone : gitlab : gitlab.localhost line not removed from $HOSTS (insufficient write rights)" >&2
118
117
  elif ! sudo -n cp "$tmp" "$HOSTS" >/dev/null 2>&1; then
119
- echo "devzone : gitlab : ligne gitlab.localhost non retirée de $HOSTS (sudo -n indisponible ou refusé)" >&2
118
+ echo "devzone : gitlab : gitlab.localhost line not removed from $HOSTS (sudo -n unavailable or refused)" >&2
120
119
  fi
121
120
  rm -f "$tmp"
122
121
  return 0
123
122
  }
124
123
 
125
- # ---- etat : vérifier l'état de GitLab ----
126
- gitlab_etat() {
127
- # Désactivé si le namespace devzone-gitlab n'existe pas
128
- if ! gitlab_installe; then
129
- echo "désactivé"
124
+ # ---- status: check the state of GitLab ----
125
+ gitlab_status() {
126
+ # Disabled if the devzone-gitlab namespace does not exist
127
+ if ! gitlab_installed; then
128
+ echo "disabled"
130
129
  return 0
131
130
  fi
132
131
 
133
- # Vérifier que GitLab répond en readiness
132
+ # Check that GitLab answers the readiness probe
134
133
  if curl -sf http://gitlab.localhost:8929/-/readiness >/dev/null 2>&1 || curl -sf http://gitlab.localhost:8929/users/sign_in >/dev/null 2>&1; then
135
- # Vérifier le runner en ligne ou hors ligne
136
- local runner_status="hors ligne"
134
+ # Check whether the runner is online or offline
135
+ local runner_status="offline"
137
136
  if [ -f "$GITLAB_SECRETS_DIR/root-token" ]; then
138
137
  local token count
139
138
  token="$(cat "$GITLAB_SECRETS_DIR/root-token")"
140
139
  count="$(curl -s --header "PRIVATE-TOKEN: $token" "http://gitlab.localhost:8929/api/v4/runners/all?status=online" 2>/dev/null | jq -r 'length' 2>/dev/null || true)"
141
140
  if [ "${count:-0}" -gt 0 ] 2>/dev/null; then
142
- runner_status="en ligne"
141
+ runner_status="online"
143
142
  fi
144
143
  fi
145
- echo "prêt : http://gitlab.localhost:8929, runner ${runner_status}"
144
+ echo "ready: http://gitlab.localhost:8929, runner ${runner_status}"
146
145
  else
147
- echo "en échec : devzone apply"
146
+ echo "failed: devzone apply"
148
147
  fi
149
148
  return 0
150
149
  }
151
150
 
152
- # Gestion des sous-commandes
151
+ # Subcommand dispatch
153
152
  case "${1:-}" in
154
- install) gitlab_installer ;;
155
- uninstall) gitlab_desinstaller "${@:2}" ;;
156
- migrate) shift; gitlab_migrer "$@" ;;
157
- installe) gitlab_installe ;;
158
- status) gitlab_etat ;;
159
- seed) gitlab_seed_commande ;;
160
- new-password) gitlab_nouveau_mdp "${@:2}" ;;
161
- relay-start) gitlab_relais_lancer ;;
162
- relay-stop) gitlab_relais_arreter ;;
163
- relay-status) gitlab_relais_etat ;;
164
- hote-poser) gitlab_hote_poser ;;
165
- hote-retirer) gitlab_hote_retirer ;;
166
- *) echo "devzone : commande inconnue : ${1:-} (devzone gitlab --help)" >&2
153
+ install) gitlab_install ;;
154
+ uninstall) gitlab_uninstall "${@:2}" ;;
155
+ migrate) shift; gitlab_migrate "$@" ;;
156
+ installe) gitlab_installed ;;
157
+ status) gitlab_status ;;
158
+ seed) gitlab_seed_command ;;
159
+ new-password) gitlab_new_password "${@:2}" ;;
160
+ relay-start) gitlab_relay_start ;;
161
+ relay-stop) gitlab_relay_stop ;;
162
+ relay-status) gitlab_relay_status ;;
163
+ hote-poser) gitlab_host_set ;;
164
+ hote-retirer) gitlab_host_remove ;;
165
+ *) echo "devzone : unknown command : ${1:-} (devzone gitlab --help)" >&2
167
166
  exit 1
168
167
  ;;
169
168
  esac