devzone 2.0.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 (90) hide show
  1. package/.devcontainer/agent-errors.sh +6 -6
  2. package/.devcontainer/agent-pod-manifest.sh +4 -4
  3. package/.devcontainer/agent-session.sh +2 -2
  4. package/.devcontainer/agent-state-json.sh +2 -2
  5. package/.devcontainer/agent-workspace.sh +1 -1
  6. package/.devcontainer/agent.sh +7 -7
  7. package/.devcontainer/ai/host-models.sh +2 -2
  8. package/.devcontainer/ai/plugins/devzone-guard-v2.js +3 -3
  9. package/.devcontainer/ai/plugins/devzone-guard.js +3 -3
  10. package/.devcontainer/argocd/argocd.sh +90 -89
  11. package/.devcontainer/argocd/catalog-argocd.sh +2 -2
  12. package/.devcontainer/argocd/services-hook.sh +3 -3
  13. package/.devcontainer/argocd/services.sh +1 -1
  14. package/.devcontainer/catalog/app.sh +114 -116
  15. package/.devcontainer/catalog/catalog-watcher.sh +62 -62
  16. package/.devcontainer/catalog/mysql/app.conf +1 -1
  17. package/.devcontainer/catalog/mysql/install.sh +40 -40
  18. package/.devcontainer/catalog/mysql/mysql.sh +141 -141
  19. package/.devcontainer/catalog/mysql/volume.sh +39 -39
  20. package/.devcontainer/catalog.sh +112 -112
  21. package/.devcontainer/chart-direct.sh +1 -1
  22. package/.devcontainer/cluster.sh +216 -218
  23. package/.devcontainer/clusters.sh +41 -41
  24. package/.devcontainer/devzone +92 -1495
  25. package/.devcontainer/devzone-ai-guard.sh +76 -0
  26. package/.devcontainer/devzone-ai.sh +201 -0
  27. package/.devcontainer/devzone-cluster.sh +210 -0
  28. package/.devcontainer/devzone-modules.sh +126 -0
  29. package/.devcontainer/devzone-platform.sh +189 -0
  30. package/.devcontainer/devzone-repair.sh +94 -0
  31. package/.devcontainer/devzone-services.sh +241 -0
  32. package/.devcontainer/devzone-skill.sh +97 -0
  33. package/.devcontainer/devzone-status.sh +140 -0
  34. package/.devcontainer/devzone-version.sh +78 -0
  35. package/.devcontainer/git-identity.sh +28 -0
  36. package/.devcontainer/gitlab/chart.sh +2 -2
  37. package/.devcontainer/gitlab/gitlab.sh +81 -82
  38. package/.devcontainer/gitlab/installation.sh +109 -109
  39. package/.devcontainer/gitlab/secrets.sh +47 -47
  40. package/.devcontainer/gitlab/seed.sh +77 -77
  41. package/.devcontainer/gitlab/test-gitlab.sh +242 -243
  42. package/.devcontainer/help.sh +1 -1
  43. package/.devcontainer/isolation.sh +30 -30
  44. package/.devcontainer/kind-wrapper.sh +17 -17
  45. package/.devcontainer/kube-account.sh +112 -113
  46. package/.devcontainer/kube-config.sh +45 -46
  47. package/.devcontainer/{invite-kube.sh → kube-prompt.sh} +6 -6
  48. package/.devcontainer/kube-reachable.sh +40 -40
  49. package/.devcontainer/memory.sh +1 -1
  50. package/.devcontainer/metrics-server.sh +2 -2
  51. package/.devcontainer/opencode.jsonc +2 -2
  52. package/.devcontainer/packages.sh +136 -135
  53. package/.devcontainer/password.sh +1 -1
  54. package/.devcontainer/ports-auto.sh +152 -153
  55. package/.devcontainer/ports-json.sh +16 -15
  56. package/.devcontainer/ports.sh +126 -122
  57. package/.devcontainer/post-create.sh +52 -52
  58. package/.devcontainer/postgres/postgres.sh +174 -174
  59. package/.devcontainer/rename-legacy-files.sh +103 -0
  60. package/.devcontainer/services-admin.sh +3 -3
  61. package/.devcontainer/skills/devzone/SKILL.md +40 -41
  62. package/.devcontainer/startup.sh +48 -49
  63. package/.devcontainer/state-gitops.sh +1 -1
  64. package/.devcontainer/state-json.sh +36 -62
  65. package/.devcontainer/state.sh +2 -2
  66. package/.devcontainer/workspace-init.sh +16 -2
  67. package/Makefile +1 -1
  68. package/README.md +195 -194
  69. package/charts/devzone-workspace/templates/statefulset.yaml +1 -1
  70. package/manage/devzone +5 -7
  71. package/manage/scripts/argocd-workspace.sh +1 -1
  72. package/manage/scripts/check-names.sh +6 -5
  73. package/manage/scripts/create-cluster.sh +1 -1
  74. package/manage/scripts/create-mode.sh +2 -2
  75. package/manage/scripts/devzone-create.sh +3 -3
  76. package/manage/scripts/devzone-manifest.sh +1 -1
  77. package/manage/scripts/devzone-update.sh +12 -8
  78. package/manage/scripts/launch.sh +7 -48
  79. package/manage/scripts/migrate-revert.sh +3 -3
  80. package/manage/scripts/migrate.sh +7 -13
  81. package/manage/scripts/ports-apps.sh +1 -1
  82. package/manage/scripts/ports-workspace.sh +7 -7
  83. package/manage/scripts/uninstall.sh +8 -8
  84. package/manage/scripts/workspace-egress.sh +2 -2
  85. package/manage/scripts/workspace-update.sh +5 -2
  86. package/manage/scripts/workspace-wait.sh +2 -2
  87. package/package.json +1 -1
  88. package/.devcontainer/docker-relay.sh +0 -149
  89. package/.devcontainer/docker-without-host.sh +0 -12
  90. package/.devcontainer/git-identite.sh +0 -28
@@ -1,10 +1,10 @@
1
1
  #!/usr/bin/env bash
2
- # Installation et migration de GitLab dans le cluster des services (#396).
3
- # Sourcé par gitlab.sh : namespace devzone-gitlab (suffixé par instance),
4
- # vérification de la mémoire allouable, Helm avec le contexte devzone,
5
- # relais port-forward, runner et migration depuis l'ancien cluster kind.
6
- # Le chart enveloppe charts/devzone-gitlab (#538) porte les dépendances et les
7
- # valeurs ; chart.sh (helm direct) et argocd.sh (Application) l'installent.
2
+ # Installation and migration of GitLab in the services cluster (#396).
3
+ # Sourced by gitlab.sh: devzone-gitlab namespace (suffixed per instance),
4
+ # check of the allocatable memory, Helm with the devzone context, port-forward
5
+ # relay, runner and migration from the old kind cluster.
6
+ # The wrapper chart charts/devzone-gitlab (#538) holds the dependencies and the
7
+ # values; chart.sh (direct helm) and argocd.sh (Application) install it.
8
8
 
9
9
  # Shared memory check of the services cluster (#608): quantity_ki,
10
10
  # memory_cluster_ki and check_module_memory.
@@ -12,38 +12,38 @@
12
12
  # shellcheck disable=SC1091
13
13
  . "$ICI/../memory.sh"
14
14
 
15
- # Namespace isolé du module : un par instance, comme postgres
15
+ # Namespace isolated from the module: one per instance, like postgres
16
16
  GITLAB_NS="devzone-gitlab${INSTANCE_SUFFIX}"
17
- # Ancien cluster kind de GitLab, supprimé par « devzone gitlab migrate »
18
- GITLAB_ANCIEN_CLUSTER="gitlab${INSTANCE_SUFFIX}"
19
- GITLAB_ANCIEN_CONTEXTE="kind-gitlab${INSTANCE_SUFFIX}"
20
-
21
- # Namespace présent dans le cluster des services : GitLab est installé.
22
- # Lecture des namespaces réservée à l'administrateur (#430).
23
- gitlab_installe() {
24
- compte_admin "$(compte_ctx)" get namespace "$GITLAB_NS" >/dev/null 2>&1
17
+ # Old kind cluster of GitLab, deleted by "devzone gitlab migrate"
18
+ GITLAB_OLD_CLUSTER="gitlab${INSTANCE_SUFFIX}"
19
+ GITLAB_OLD_CONTEXT="kind-gitlab${INSTANCE_SUFFIX}"
20
+
21
+ # Namespace present in the services cluster: GitLab is installed.
22
+ # Reading the namespaces is reserved to the administrator (#430).
23
+ gitlab_installed() {
24
+ account_admin "$(account_context)" get namespace "$GITLAB_NS" >/dev/null 2>&1
25
25
  }
26
26
 
27
- # Crée le namespace, étiquette et autorise le compte limité (#430), pose l'isolation.
28
- gitlab_namespace_preparer() {
27
+ # Creates the namespace, labels it and allows the limited account (#430), sets the isolation.
28
+ gitlab_namespace_prepare() {
29
29
  local ctx
30
- ctx="$(compte_ctx)"
31
- compte_namespace "$ctx" "$GITLAB_NS"
32
- namespace_isoler "$GITLAB_NS"
30
+ ctx="$(account_context)"
31
+ account_namespace "$ctx" "$GITLAB_NS"
32
+ namespace_isolate "$GITLAB_NS"
33
33
  }
34
34
 
35
- # Installe GitLab et son runner dans le cluster des services, puis prépare
36
- # l'accès (relais web/SSH, /etc/hosts) et le seed des données de test.
37
- gitlab_installer() {
38
- echo "▶ Vérification de la mémoire allouable du cluster des services…"
35
+ # Installs GitLab and its runner in the services cluster, then prepares the
36
+ # access (web/SSH relay, /etc/hosts) and the seed of the test data.
37
+ gitlab_install() {
38
+ echo "▶ Checking the allocatable memory of the services cluster…"
39
39
  check_module_memory gitlab 8 || return 2
40
40
 
41
41
  mkdir -p "$GITLAB_SECRETS_DIR"
42
- gitlab_namespace_preparer
42
+ gitlab_namespace_prepare
43
43
 
44
- # Secret Rails (#347) : réinstallation -> réappliquer le secret conservé avant
45
- # l'installation (le chart le réutilise, sessions navigateur valides)
46
- gitlab_secrets_appliquer
44
+ # Rails secret (#347): reinstallation -> apply the kept secret again before
45
+ # the installation (the chart reuses it, browser sessions stay valid)
46
+ gitlab_secrets_apply
47
47
  gitlab_runner_ancien_retirer
48
48
 
49
49
  # Argo CD holds the chart when the module is on (#538): the Application
@@ -55,139 +55,139 @@ gitlab_installer() {
55
55
  gitlab_release_adopter
56
56
  gitlab_application_apply || return 1
57
57
  else
58
- echo "▶ Installation du chart GitLab dans ${GITLAB_NS}…"
58
+ echo "▶ Installing the GitLab chart in ${GITLAB_NS}…"
59
59
  gitlab_chart_depend
60
60
  gitlab_helm_pass 0 || return 1
61
61
  fi
62
62
 
63
- # Relais avant l'attente : curl et git en HTTP résolvent *.localhost vers
64
- # la boucle locale et n'atteignent GitLab que par ces port-forward (#320)
65
- gitlab_relais_lancer || return 1
63
+ # Relay before the wait: curl and git in HTTP resolve *.localhost to the
64
+ # loopback and reach GitLab only through these port-forwards (#320)
65
+ gitlab_relay_start || return 1
66
66
 
67
- # Nom gitlab.localhost dans /etc/hosts avant l'attente : ssh, glab et
68
- # getent en ont besoin dès que le service monte (curl, lui, résout seul)
69
- gitlab_hote_poser || true
67
+ # gitlab.localhost name in /etc/hosts before the wait: ssh, glab and
68
+ # getent need it as soon as the service is up (curl resolves it itself)
69
+ gitlab_host_set || true
70
70
 
71
- gitlab_attendre_pret
71
+ gitlab_wait_ready
72
72
  gitlab_seed
73
- if [ ! -f "$GITLAB_RAILS_FICHIER" ]; then
74
- gitlab_secrets_copier
73
+ if [ ! -f "$GITLAB_RAILS_FILE" ]; then
74
+ gitlab_secrets_copy
75
75
  fi
76
76
  if [ "$par_argocd" = 0 ]; then
77
- echo "▶ Exécuteur GitLab Runner…"
77
+ echo "▶ GitLab Runner executor…"
78
78
  gitlab_helm_pass 1 || return 1
79
79
  fi
80
80
 
81
- gitlab_secrets_avertir
81
+ gitlab_secrets_warn
82
82
 
83
- echo "▶ Installation terminée."
84
- echo " URL : http://gitlab.localhost:8929"
85
- echo " Utilisateur : root"
86
- echo " Mot de passe root : $GITLAB_SECRETS_DIR/root-password (chmod 600)"
83
+ echo "▶ Installation complete."
84
+ echo " URL: http://gitlab.localhost:8929"
85
+ echo " User: root"
86
+ echo " Root password: $GITLAB_SECRETS_DIR/root-password (chmod 600)"
87
87
  }
88
88
 
89
- # Retire GitLab : relais, releases Helm et namespace de l'instance seulement.
90
- # Le secret Rails est gardé (sessions du navigateur valides à la réinstallation),
91
- # sauf désinstallation complète voulue (--yes) : il part alors avec les données.
92
- gitlab_desinstaller() {
93
- local supprimer_secret="" arg
89
+ # Removes GitLab: relays, Helm releases and the namespace of the instance only.
90
+ # The Rails secret is kept (browser sessions valid at the reinstallation),
91
+ # unless a complete uninstall is wanted (--yes): it then goes with the data.
92
+ gitlab_uninstall() {
93
+ local delete_secret="" arg
94
94
  for arg in "$@"; do
95
95
  case "$arg" in
96
- --yes) supprimer_secret=1 ;;
97
- *) echo "devzone : gitlab uninstall : argument inconnu : $arg" >&2; return 2 ;;
96
+ --yes) delete_secret=1 ;;
97
+ *) echo "devzone : gitlab uninstall : unknown argument : $arg" >&2; return 2 ;;
98
98
  esac
99
99
  done
100
- echo "▶ Désinstallation de GitLab…"
101
- gitlab_relais_arreter
102
- rm -rf "$(relais_dossier gitlab-web)" "$(relais_dossier gitlab-ssh)" \
103
- "$(relais_dossier gitlab-8929)" "$(relais_dossier gitlab-2224)"
104
- # Application tenue par Argo CD (#538) : ses ressources partent avec elle
100
+ echo "▶ Uninstalling GitLab…"
101
+ gitlab_relay_stop
102
+ rm -rf "$(relay_dir gitlab-web)" "$(relay_dir gitlab-ssh)" \
103
+ "$(relay_dir gitlab-8929)" "$(relay_dir gitlab-2224)"
104
+ # Application held by Argo CD (#538): its resources go with it
105
105
  gitlab_application_retirer || true
106
- compte_helm "$(compte_ctx)" uninstall gitlab --namespace "$GITLAB_NS" >/dev/null 2>&1 || true
106
+ account_helm "$(account_context)" uninstall gitlab --namespace "$GITLAB_NS" >/dev/null 2>&1 || true
107
107
  gitlab_runner_ancien_retirer
108
- # RoleBinding retiré puis namespace supprimé par l'administrateur (#430)
109
- compte_retirer "$(compte_ctx)" "$GITLAB_NS" >/dev/null 2>&1 || true
110
- compte_admin "$(compte_ctx)" delete namespace "$GITLAB_NS" --ignore-not-found >/dev/null 2>&1 || true
111
- if [ -n "$supprimer_secret" ]; then
108
+ # RoleBinding removed, then the namespace deleted by the administrator (#430)
109
+ account_remove "$(account_context)" "$GITLAB_NS" >/dev/null 2>&1 || true
110
+ account_admin "$(account_context)" delete namespace "$GITLAB_NS" --ignore-not-found >/dev/null 2>&1 || true
111
+ if [ -n "$delete_secret" ]; then
112
112
  rm -rf "$GITLAB_SECRETS_DIR"
113
- echo "secret Rails supprimé avec les données de GitLab."
113
+ echo "Rails secret deleted with the GitLab data."
114
114
  elif [ -d "$GITLAB_SECRETS_DIR" ]; then
115
115
  find "$GITLAB_SECRETS_DIR" -mindepth 1 ! -name rails-secret.yaml -exec rm -rf {} + 2>/dev/null || true
116
- if [ -f "$GITLAB_RAILS_FICHIER" ]; then
117
- echo "secret Rails gardé dans workspace/.gitlab/rails-secret.yaml (sessions du navigateur valides à la réinstallation)"
116
+ if [ -f "$GITLAB_RAILS_FILE" ]; then
117
+ echo "Rails secret kept in workspace/.gitlab/rails-secret.yaml (browser sessions valid at reinstallation)"
118
118
  fi
119
119
  fi
120
- gitlab_hote_retirer
121
- echo "✔ GitLab désinstallé."
120
+ gitlab_host_remove
121
+ echo "✔ GitLab uninstalled."
122
122
  regenerer_identifiants
123
123
  }
124
124
 
125
- # Migration : installe et seed dans le cluster des services, puis supprime
126
- # l'ancien cluster kind-gitlab après confirmation (ou --yes).
127
- gitlab_migrer() {
128
- local oui="" arg reponse
125
+ # Migration: installs and seeds in the services cluster, then deletes the old
126
+ # kind-gitlab cluster after confirmation (or --yes).
127
+ gitlab_migrate() {
128
+ local yes_flag="" arg answer
129
129
  for arg in "$@"; do
130
130
  case "$arg" in
131
- --yes) oui=1 ;;
132
- *) echo "devzone : gitlab migrate : argument inconnu : $arg (devzone gitlab migrate [--yes])" >&2; return 2 ;;
131
+ --yes) yes_flag=1 ;;
132
+ *) echo "devzone : gitlab migrate : unknown argument : $arg (devzone gitlab migrate [--yes])" >&2; return 2 ;;
133
133
  esac
134
134
  done
135
135
 
136
- echo "▶ Migration de GitLab depuis l'ancien cluster kind…"
137
- echo " C'est un GitLab de test : le projet de démo et le runner sont recréés, le reste est perdu."
138
- gitlab_installer || return $?
136
+ echo "▶ Migrating GitLab from the old kind cluster…"
137
+ echo " This is a test GitLab: the demo project and the runner are recreated, the rest is lost."
138
+ gitlab_install || return $?
139
139
 
140
- if ! kind get clusters 2>/dev/null | grep -qx "$GITLAB_ANCIEN_CLUSTER"; then
141
- echo "✔ Aucun ancien cluster $GITLAB_ANCIEN_CONTEXTE à supprimer."
140
+ if ! kind get clusters 2>/dev/null | grep -qx "$GITLAB_OLD_CLUSTER"; then
141
+ echo "✔ No old cluster $GITLAB_OLD_CONTEXT to delete."
142
142
  return 0
143
143
  fi
144
144
 
145
- if [ -z "$oui" ]; then
146
- if ! cluster_interactif; then
147
- echo "devzone : gitlab : confirmation impossible sans terminal : devzone gitlab migrate --yes (ancien cluster $GITLAB_ANCIEN_CONTEXTE conservé)" >&2
145
+ if [ -z "$yes_flag" ]; then
146
+ if ! cluster_interactive; then
147
+ echo "devzone : gitlab : confirmation impossible without a terminal: devzone gitlab migrate --yes (old cluster $GITLAB_OLD_CONTEXT kept)" >&2
148
148
  return 2
149
149
  fi
150
- printf "Supprimer l'ancien cluster %s et ses données ? [o/N] " "$GITLAB_ANCIEN_CONTEXTE" >&2
151
- read -r reponse || reponse=""
152
- case "$reponse" in
153
- o | O | oui) ;;
154
- *) echo "Abandon : ancien cluster $GITLAB_ANCIEN_CONTEXTE conservé."; return 0 ;;
150
+ printf "Delete the old cluster %s and its data? [y/N] " "$GITLAB_OLD_CONTEXT" >&2
151
+ read -r answer || answer=""
152
+ case "$answer" in
153
+ y | Y | yes) ;;
154
+ *) echo "Aborted: old cluster $GITLAB_OLD_CONTEXT kept."; return 0 ;;
155
155
  esac
156
156
  fi
157
157
 
158
- kind delete cluster --name "$GITLAB_ANCIEN_CLUSTER"
159
- kubectl config delete-context "$GITLAB_ANCIEN_CONTEXTE" >/dev/null 2>&1 || true
160
- kubectl config delete-cluster "$GITLAB_ANCIEN_CONTEXTE" >/dev/null 2>&1 || true
161
- kubectl config delete-user "$GITLAB_ANCIEN_CONTEXTE" >/dev/null 2>&1 || true
162
- echo "✔ Ancien cluster $GITLAB_ANCIEN_CONTEXTE supprimé."
158
+ kind delete cluster --name "$GITLAB_OLD_CLUSTER"
159
+ kubectl config delete-context "$GITLAB_OLD_CONTEXT" >/dev/null 2>&1 || true
160
+ kubectl config delete-cluster "$GITLAB_OLD_CONTEXT" >/dev/null 2>&1 || true
161
+ kubectl config delete-user "$GITLAB_OLD_CONTEXT" >/dev/null 2>&1 || true
162
+ echo "✔ Old cluster $GITLAB_OLD_CONTEXT deleted."
163
163
  }
164
164
 
165
- # Accès web et SSH : port-forward vers les services ClusterIP du namespace.
166
- gitlab_relais_lancer() {
167
- relais_lancer gitlab-web devzone "$GITLAB_NS" svc/gitlab-webservice-default 8929:8181
168
- relais_lancer gitlab-ssh devzone "$GITLAB_NS" svc/gitlab-gitlab-shell 2224:22
165
+ # Web and SSH access: port-forward to the ClusterIP services of the namespace.
166
+ gitlab_relay_start() {
167
+ relay_start gitlab-web devzone "$GITLAB_NS" svc/gitlab-webservice-default 8929:8181
168
+ relay_start gitlab-ssh devzone "$GITLAB_NS" svc/gitlab-gitlab-shell 2224:22
169
169
  }
170
170
 
171
- # Arrête les deux relais du module.
172
- gitlab_relais_arreter() {
173
- relais_arreter gitlab-web
174
- relais_arreter gitlab-ssh
171
+ # Stops the two relays of the module.
172
+ gitlab_relay_stop() {
173
+ relay_stop gitlab-web
174
+ relay_stop gitlab-ssh
175
175
  }
176
176
 
177
- # État des relais : code 0 seulement si les deux tournent.
178
- gitlab_relais_etat() {
179
- local manquants=""
180
- relais_actif gitlab-web || manquants="$manquants 8929"
181
- relais_actif gitlab-ssh || manquants="$manquants 2224"
182
- if [ -n "$manquants" ]; then
183
- echo "relais gitlab arrêté sur${manquants}"
177
+ # State of the relays: code 0 only if both are running.
178
+ gitlab_relay_status() {
179
+ local missing=""
180
+ relay_active gitlab-web || missing="$missing 8929"
181
+ relay_active gitlab-ssh || missing="$missing 2224"
182
+ if [ -n "$missing" ]; then
183
+ echo "gitlab relay stopped on${missing}"
184
184
  return 1
185
185
  fi
186
186
  return 0
187
187
  }
188
188
 
189
- # Vrai si un ancien cluster kind-gitlab existe encore (avertissement du
190
- # récapitulatif, tant que la migration n'a pas été faite).
191
- gitlab_ancien_cluster_existe() {
192
- kind get clusters 2>/dev/null | grep -qx "$GITLAB_ANCIEN_CLUSTER"
189
+ # True if an old kind-gitlab cluster still exists (warning of the summary,
190
+ # as long as the migration has not been done).
191
+ gitlab_old_cluster_exists() {
192
+ kind get clusters 2>/dev/null | grep -qx "$GITLAB_OLD_CLUSTER"
193
193
  }
@@ -1,23 +1,23 @@
1
1
  #!/usr/bin/env bash
2
- # Secret Rails GitLab (#347) : conservation dans workspace/.gitlab du secret
3
- # gitlab-rails-secret du namespace devzone-gitlab, source des secrets Rails.
4
- # À la première installation, le secret du cluster est copié dans
5
- # workspace/.gitlab/rails-secret.yaml (600, ignoré par git) ; à une réinstallation,
6
- # s'il existe, il est réappliqué avant helm upgrade --install (le chart le réutilise
7
- # et les sessions du navigateur restent valides, sans 422). À défaut, si les secrets
8
- # ont été perdus, la fin d'installation et le récapitulatif préviennent.
2
+ # GitLab Rails secret (#347): kept in workspace/.gitlab, the gitlab-rails-secret
3
+ # secret of the devzone-gitlab namespace, source of the Rails secrets.
4
+ # At the first installation, the secret of the cluster is copied to
5
+ # workspace/.gitlab/rails-secret.yaml (600, ignored by git); at a reinstallation,
6
+ # if it exists, it is applied again before helm upgrade --install (the chart
7
+ # reuses it and the browser sessions stay valid, without 422). Otherwise, if the
8
+ # secrets were lost, the end of the installation and the summary warn.
9
9
 
10
- # Nom du secret Rails et fichier source des secrets du module
10
+ # Name of the Rails secret and source file of the secrets of the module
11
11
  GITLAB_RAILS_SECRET="gitlab-rails-secret"
12
- GITLAB_RAILS_FICHIER="$GITLAB_SECRETS_DIR/rails-secret.yaml"
12
+ GITLAB_RAILS_FILE="$GITLAB_SECRETS_DIR/rails-secret.yaml"
13
13
 
14
- # Filtre jq : retire les champs propres au cluster (identité, version, gestion,
15
- # annotations du dernier apply) et garde un manifeste JSON réappliquable.
14
+ # jq filter: removes the fields specific to the cluster (identity, version,
15
+ # management, annotations of the last apply) and keeps a re-appliable JSON manifest.
16
16
  GITLAB_RAILS_JQ='del(.metadata.resourceVersion, .metadata.uid, .metadata.creationTimestamp, .metadata.managedFields, .metadata.ownerReferences, .metadata.annotations["kubectl.kubernetes.io/last-applied-configuration"])'
17
17
 
18
- # Lit le secret Rails du cluster et écrit un vrai manifeste Secret en JSON (première
19
- # installation). Rien n'est écrit si la lecture échoue ou si le secret est absent.
20
- gitlab_secrets_copier() {
18
+ # Reads the Rails secret of the cluster and writes a real Secret manifest in JSON
19
+ # (first installation). Nothing is written if the read fails or if the secret is missing.
20
+ gitlab_secrets_copy() {
21
21
  local secret tmp
22
22
  secret="$(kubectl --context devzone get secret -n "$GITLAB_NS" \
23
23
  "$GITLAB_RAILS_SECRET" -o json 2>/dev/null)" || return 0
@@ -32,64 +32,64 @@ gitlab_secrets_copier() {
32
32
  rm -f "$tmp"
33
33
  return 0
34
34
  }
35
- mv -f "$tmp" "$GITLAB_RAILS_FICHIER"
35
+ mv -f "$tmp" "$GITLAB_RAILS_FILE"
36
36
  }
37
37
 
38
- # Réapplique le secret Rails depuis le fichier source avant un helm upgrade
39
- # --install : le chart réutilise le secret existant, les sessions du navigateur
40
- # restent valides après une réinstallation. L'échec est affiché et rendu.
41
- gitlab_secrets_appliquer() {
42
- if [ ! -f "$GITLAB_RAILS_FICHIER" ]; then
38
+ # Applies the Rails secret again from the source file before a helm upgrade
39
+ # --install: the chart reuses the existing secret, the browser sessions stay
40
+ # valid after a reinstallation. A failure is shown and returned.
41
+ gitlab_secrets_apply() {
42
+ if [ ! -f "$GITLAB_RAILS_FILE" ]; then
43
43
  return 0
44
44
  fi
45
- kubectl --context devzone -n "$GITLAB_NS" apply -f "$GITLAB_RAILS_FICHIER"
45
+ kubectl --context devzone -n "$GITLAB_NS" apply -f "$GITLAB_RAILS_FILE"
46
46
  }
47
47
 
48
- # Avertit si le secret Rails n'a pas pu être conservé : la réinstallation régénère
49
- # le secret et les sessions du navigateur sont invalidées (422).
50
- gitlab_secrets_avertir() {
51
- if [ ! -f "$GITLAB_RAILS_FICHIER" ]; then
52
- echo "GitLab réinstallé : si le navigateur affiche 422, supprimez les données de site de gitlab.localhost"
48
+ # Warns if the Rails secret could not be kept: the reinstallation generates a new
49
+ # secret and the browser sessions are invalidated (422).
50
+ gitlab_secrets_warn() {
51
+ if [ ! -f "$GITLAB_RAILS_FILE" ]; then
52
+ echo "GitLab reinstalled: if the browser shows 422, delete the site data of gitlab.localhost"
53
53
  fi
54
54
  }
55
55
 
56
- # Mot de passe aléatoire (root | dev) : script Ruby passé sur l'entrée standard
57
- # de gitlab-rails runner (jamais dans la ligne de commande du pod), puis le
58
- # fichier source et le regroupé .password sont mis à jour si le runner confirme.
59
- # Rien n'est affiché, seulement le chemin.
60
- gitlab_nouveau_mdp() {
61
- local utilisateur="${1:-}" mdp pod script sortie fichier
62
- case "$utilisateur" in
56
+ # Random password (root | dev): Ruby script passed on the standard input of
57
+ # gitlab-rails runner (never on the pod command line), then the source file and
58
+ # the grouped .password are updated if the runner confirms. Nothing is shown,
59
+ # only the path.
60
+ gitlab_new_password() {
61
+ local user="${1:-}" pass pod script output file
62
+ case "$user" in
63
63
  root | dev) ;;
64
64
  *)
65
- echo "devzone : gitlab : utilisateur inconnu : ${utilisateur:-(absent)} (devzone gitlab new-password [root|dev])" >&2
65
+ echo "devzone : gitlab : unknown user : ${user:-(missing)} (devzone gitlab new-password [root|dev])" >&2
66
66
  return 2
67
67
  ;;
68
68
  esac
69
- mdp="$(openssl rand -hex 24)"
69
+ pass="$(openssl rand -hex 24)"
70
70
  pod="$(kubectl --context devzone get pod -n "$GITLAB_NS" -l app=toolbox -o jsonpath='{.items[0].metadata.name}' 2>/dev/null || true)"
71
71
  if [ -z "$pod" ]; then
72
- echo "devzone : gitlab : pod toolbox (label app=toolbox) introuvable, mot de passe non changé." >&2
72
+ echo "devzone : gitlab : toolbox pod (label app=toolbox) not found, password not changed." >&2
73
73
  return 1
74
74
  fi
75
- script="u = User.find_by_username(\"$utilisateur\")
76
- u.password = \"$mdp\"
77
- u.password_confirmation = \"$mdp\"
75
+ script="u = User.find_by_username(\"$user\")
76
+ u.password = \"$pass\"
77
+ u.password_confirmation = \"$pass\"
78
78
  u.save!
79
79
  puts \"OK\""
80
- if ! sortie="$(printf '%s\n' "$script" | kubectl --context devzone exec -i -n "$GITLAB_NS" "$pod" -- gitlab-rails runner -)"; then
81
- echo "devzone : gitlab : mot de passe (gitlab-rails runner) non appliqué." >&2
80
+ if ! output="$(printf '%s\n' "$script" | kubectl --context devzone exec -i -n "$GITLAB_NS" "$pod" -- gitlab-rails runner -)"; then
81
+ echo "devzone : gitlab : password (gitlab-rails runner) not applied." >&2
82
82
  return 1
83
83
  fi
84
- if [[ "$sortie" != *OK* ]]; then
85
- echo "devzone : gitlab : mot de passe non confirmé par gitlab-rails runner." >&2
84
+ if [[ "$output" != *OK* ]]; then
85
+ echo "devzone : gitlab : password not confirmed by gitlab-rails runner." >&2
86
86
  return 1
87
87
  fi
88
- fichier="$GITLAB_SECRETS_DIR/$utilisateur-password"
88
+ file="$GITLAB_SECRETS_DIR/$user-password"
89
89
  mkdir -p "$GITLAB_SECRETS_DIR" || return 1
90
- (umask 077 && printf '%s' "$mdp" >"$fichier") || return 1
91
- chmod 600 "$fichier"
90
+ (umask 077 && printf '%s' "$pass" >"$file") || return 1
91
+ chmod 600 "$file"
92
92
  password_regenerate ||
93
- echo "devzone : gitlab : identifiants regroupés non mis à jour (devzone passwords)" >&2
93
+ echo "devzone : gitlab : grouped credentials not updated (devzone passwords)" >&2
94
94
  printf '%s\n' "$RACINE/.password"
95
95
  }