devzone 7.5.4 → 7.6.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.
@@ -77,29 +77,7 @@ IA_OPENCODE=opencode-ai@1.19.6
77
77
  IA_PAQUETS=("$IA_CLAUDE" "$IA_OPENCODE")
78
78
  IA_NOMS=("${IA_CLAUDE%@*}" "${IA_OPENCODE%@*}")
79
79
 
80
- # glab (GitLab CLI), installed only when the gitlab platform is chosen: binary
81
- # of the official release (gitlab.com/gitlab-org/cli) in ~/.local/bin, SHA-256
82
- # sum of its archive checked; removed when going back to github. All its calls
83
- # go through this path (never PATH: ~/.local/bin is not necessarily in it); the
84
- # state and the login too.
85
- GLAB="$HOME/.local/bin/glab"
86
- GLAB_VERSION=v1.126.0
87
- GLAB_SOMME_ARM64=de5e92c9c8b306eeebb19daa854d48101b78328850e7b9cd677ecd6f98cd4391
88
- GLAB_SOMME_AMD64=f386519ba83e9482979992ee7f60eeebee4d95b950f95f4fe7289e0a1b1ea74c
89
- # gitlab module instance: its default URL and the root token of its seed
90
- GITLAB_URL_MODULE=http://gitlab.localhost:8929
91
80
 
92
- # Functions of devzone, by topic (sourced here, defined before any command runs)
93
- # shellcheck source=SCRIPTDIR/devzone-modules.sh
94
- # shellcheck disable=SC1091
95
- . "$ICI/devzone-modules.sh"
96
- # The AI module and its guard are handled by the Go command of the pod (#882).
97
- # shellcheck source=SCRIPTDIR/devzone-services.sh
98
- # shellcheck disable=SC1091
99
- . "$ICI/devzone-services.sh"
100
- # shellcheck source=SCRIPTDIR/devzone-platform.sh
101
- # shellcheck disable=SC1091
102
- . "$ICI/devzone-platform.sh"
103
81
 
104
82
  case "${1:-}" in
105
83
  "" | status | modules)
@@ -128,34 +106,12 @@ case "${1:-}" in
128
106
  exit 127
129
107
  fi
130
108
  ;;
131
- enable) change_module on "${2:-}" "${@:3}" ;;
132
- disable) change_module off "${2:-}" "${@:3}" ;;
133
- apply)
134
- migrate_llm
135
- # The user confirms the current state (#417, step 4): the watchers
136
- # may uninstall again
137
- DEVZONE_STATE="$ETAT" bash "$ICI/devzone" state recovery-confirm
138
- "${DEVZONE_HOST_BIN:?devzone: Go pod binary unavailable}" apply-repowarden
139
- [ "$(value_of ai)" = off ] || DEVZONE_STATE="$ETAT" "$ICI/devzone" ai apply on
140
- # gitlab, postgres, argocd: installed from the workstation in the
141
- # Kubernetes workspace pod (#528), by their installer elsewhere
142
- [ "$(value_of gitlab)" = off ] || apply_service gitlab
143
- [ "$(value_of postgres)" = off ] || apply_service postgres
144
- [ "$(value_of mysql)" = off ] || apply_mysql on
145
- [ "$(value_of argocd)" = off ] || apply_service argocd
146
- ;;
147
- is-enabled)
148
- is_known "${2:-}" || { echo "devzone : unknown module : ${2:-(none)}" >&2; exit 2; }
149
- # Silent test: code 0 if the module is active, 1 otherwise, without
150
- # writing anything
151
- [ "$(value_of "$2")" = on ]
152
- ;;
153
109
  build)
154
110
  bash "$ICI/workspace-build.sh" "${@:2}"
155
111
  ;;
156
112
  # Go only: reached when the binary did not take the call. Never call
157
113
  # "devzone" again from here, it would loop forever, see #864
158
- -h | --help | help | repair | apply-repowarden | cluster | clusters | metrics | use | kube | ai | agent | postgres | mysql | gitlab | test-gitlab | catalog | catalog-watcher)
114
+ -h | --help | help | repair | apply-repowarden | cluster | clusters | metrics | use | kube | ai | agent | postgres | mysql | gitlab | test-gitlab | catalog | catalog-watcher | enable | disable | is-enabled | apply | platform)
159
115
  echo "devzone $1: Go binary of the pod unavailable (.devcontainer/bin)" >&2
160
116
  exit 1
161
117
  ;;
@@ -176,13 +132,6 @@ case "${1:-}" in
176
132
  exit 1
177
133
  ;;
178
134
  test-bash32) bash "$RACINE/manage/test/bash32.sh" ;;
179
- platform)
180
- if [ -n "${2:-}" ]; then
181
- change_platform "${@:2}"
182
- else
183
- platform_summary
184
- fi
185
- ;;
186
135
  *)
187
136
  echo "devzone : unknown command : $1 (devzone --help)" >&2
188
137
  exit 1
package/bin/SHA256SUMS CHANGED
@@ -1,6 +1,6 @@
1
- 2f2d92e6ded735eaeca2c18ba02be3e60f502356b4898b310891efd87673bdd6 devzone-linux-amd64
2
- 6dac6f391103c55a56a96da06fb59c2f4b57da1c457f9b43689d700bcf718f6c devzone-linux-arm64
3
- 65958c3379d10b12960b743bc3767b1b08c57c0b2efd0e15be9ec8ef567e68b3 devzone-darwin-amd64
4
- 332cf5308ee99075db106260a2f2899697f3dc525be2a173417ce0fb4092631f devzone-darwin-arm64
5
- ae67a9cbda1e533ba0508341008019b602ce688628bda17a3d85395868d29f31 devzone-windows-amd64.exe
6
- f4766767516b38f2b26d8eec97c339608ab1f38d237908fa4d3e5331d20ea17e devzone-windows-arm64.exe
1
+ e5dc4d599f8bc39bd36ffa2a940620986c96d24b47ac162d8b43acf0b0e8c98c devzone-linux-amd64
2
+ 6a0022bfecdf5938398891f19f63a7cf48319ad4035d95819f008d5aaed5ebad devzone-linux-arm64
3
+ 4afdbe24819428ffc36fc99465bf8e4d07f8c23a664e1066e96f0f7b7ef8b310 devzone-darwin-amd64
4
+ e604c3027e7526c69fc4d17a786acec72e083c41a72da3165b5ac2f8c29f840c devzone-darwin-arm64
5
+ 12b59f3edcb424654fcd5c6749dad9ef82ede5045b3c9bc3b8ea889c70dda49f devzone-windows-amd64.exe
6
+ 39aa9e3cd6812d6a0bb3c1e5311797af35c1eef3a5aa33b55ba4846206c7da77 devzone-windows-arm64.exe
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -144,9 +144,10 @@ spec:
144
144
  {{- /*
145
145
  Without command, the container runs the entrypoint of the image (bash
146
146
  for a devcontainer), which ends at once without a terminal: the pod
147
- loops on restarts. sleep infinity keeps it alive, like VS Code for a
148
- devcontainer; the workstation then enters through kubectl exec. Helm
149
- comment: not in the rendering.
147
+ loops on restarts. The command keeps it alive as PID 1 (a wait loop
148
+ that reaps the orphans, #967), like VS Code for a devcontainer; the
149
+ workstation then enters through kubectl exec. Helm comment: not in
150
+ the rendering.
150
151
  */}}
151
152
  {{- with .Values.workspace.command }}
152
153
  command: {{ toJson . }}
@@ -50,21 +50,32 @@ buildkit:
50
50
  # is mounted on /workspaces/projets, where the container starts (workingDir).
51
51
  workspace:
52
52
  # Command: run workspace-init.sh in the foreground first, then keep the pod
53
- # alive with sleep infinity (like VS Code for a devcontainer) (#503). The init
54
- # script runs before exec, its errors are ignored (|| true) and its journal is
53
+ # alive as PID 1 (like VS Code for a devcontainer) (#503). The init script
54
+ # runs before the loop, its errors are ignored (|| true) and its journal is
55
55
  # ~/.local/state/devzone/init.log. Empty = image default command.
56
- command: ["bash", "-c", "mkdir -p \"$HOME/.local/state/devzone\"; bash /usr/local/share/devzone/.devcontainer/workspace-init.sh >>\"$HOME/.local/state/devzone/init.log\" 2>&1 || true; exec sleep infinity"]
56
+ # PID 1 must reap the orphans (#967): sleep infinity did not, so the zombies
57
+ # piled up (20 000 in 2.5 days). The loop calls wait, which reaps every child
58
+ # of the shell, orphans included (they are re-parented to PID 1). TERM and INT
59
+ # exit at once, so the pod stops on time.
60
+ command: ["bash", "-c", "mkdir -p \"$HOME/.local/state/devzone\"; bash /usr/local/share/devzone/.devcontainer/workspace-init.sh >>\"$HOME/.local/state/devzone/init.log\" 2>&1 || true; trap 'exit 0' TERM INT; while true; do wait -n 2>/dev/null; sleep 1; done"]
57
61
  # Size of the projects volume.
58
62
  size: 20Gi
59
63
  storageClass: ""
60
64
 
65
+ # Resources of the workspace container (#967). Zombie processes accumulated in
66
+ # the pod (its process limit is 24 006), and the command's reaper now fixes that.
67
+ # The memory limit is raised to 8Gi as a precaution: the measured memory of the
68
+ # pod, page cache included, regularly reached 4Gi while several agents compiled
69
+ # in parallel. A zombie uses almost no memory. The cause of the claude.exe
70
+ # crashes is not proven. The limit is adjustable: change this value, or pass
71
+ # helm --set resources.limits.memory=<N>Gi on a release.
61
72
  resources:
62
73
  limits:
63
74
  cpu: "2"
64
- memory: "4Gi"
75
+ memory: "8Gi"
65
76
  requests:
66
77
  cpu: "500m"
67
- memory: "1Gi"
78
+ memory: "4Gi"
68
79
 
69
80
  persistence:
70
81
  # Identities, logins and caches, kept from one restart to the next. Each path
package/manage/devzone CHANGED
@@ -7,9 +7,6 @@
7
7
  # In the container, « devzone » is another command: the modules
8
8
  # (.devcontainer/devzone).
9
9
  # DEVZONE_NO_START=1: copy only, without starting the container (tests).
10
- # The helpers live in manage/scripts/devzone-*.sh, sourced by the command that
11
- # needs them (so --version and --help work with this file alone).
12
- # shellcheck disable=SC2034 # PACKAGE_ITEMS, GITIGNORE_LINES: read by the sourced devzone-*.sh
13
10
  set -euo pipefail
14
11
 
15
12
  # Script path. From cmd, the npm .cmd shim calls bash with the Windows path
@@ -21,21 +18,6 @@ case "$SCRIPT" in
21
18
  [A-Za-z]:[\\/]*) SCRIPT="$(cygpath -u "$SCRIPT" 2>/dev/null || echo "${SCRIPT//\\//}")" ;;
22
19
  esac
23
20
  PAQUET="$(cd "$(dirname "$(readlink -f "$SCRIPT" 2>/dev/null || echo "$SCRIPT")")/.." && pwd)"
24
- # Items copied into a devzone (same list as the « files » of package.json,
25
- # without the command manage/devzone); manage/scripts is copied apart, under manage/
26
- PACKAGE_ITEMS=(.devcontainer Makefile .gitattributes README.md LICENSE)
27
- # Lines always present in the .gitignore of a devzone: added to, never overwritten
28
- GITIGNORE_LINES=(
29
- '# Each workspace project has its own git repository'
30
- 'workspace/*'
31
- '!workspace/.gitkeep'
32
- '.DS_Store'
33
- '.devzone.log'
34
- '.devzone.state'
35
- '.password'
36
- '.devzone.backup/'
37
- )
38
-
39
21
  # Version of the package (package.json next to manage/)
40
22
  version() {
41
23
  # Path passed as an argument to node, never written in the JavaScript code of -p:
@@ -189,9 +171,10 @@ devzone $(version): development workspace in a Kubernetes cluster
189
171
  the installed package, after backing up the replaced files in
190
172
  .devzone.backup/ (the new image is used at the next workspace start)
191
173
  devzone uninstall [--yes]
192
- in a devzone folder: removes Kubernetes objects of this devzone
193
- instance (namespaces, Argo CD Applications, temporary accounts,
194
- .devzone.* files); workspace/ is kept; asks for confirmation
174
+ in a devzone folder: removes what this devzone instance created on
175
+ the host (containers, images, volumes, kind clusters, metrics-server)
176
+ and in the cluster (namespaces, Argo CD Applications, temporary
177
+ accounts); workspace/ is kept; asks for confirmation
195
178
  devzone ai [check|rapport|guard] host models, update report or tool-call guard
196
179
  devzone workspace start|stop|status|shell|update|deploy
197
180
  devzone workspace vscode|copy-to|copy-from|clone
@@ -230,19 +213,9 @@ case "${1:-}" in
230
213
  DEVZONE_BASH_ENTRY="$PAQUET/manage/devzone" "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" update "${@:2}"
231
214
  ;;
232
215
  uninstall)
233
- # Devzone folder (.devcontainer/); an older devzone has its uninstall.sh
234
- # in manage/scripts/ (new), core/scripts or scripts/ (old), or at the root
235
- uninstaller=""
236
- if [ -d .devcontainer ]; then
237
- for f in manage/scripts/uninstall.sh core/scripts/uninstall.sh scripts/uninstall.sh uninstall.sh; do
238
- if [ -f "$f" ]; then uninstaller="$f" && break; fi
239
- done
240
- fi
241
- if [ -z "$uninstaller" ]; then
242
- echo "✖ Run this in a devzone folder (uninstall.sh not found here)." >&2
243
- exit 1
244
- fi
245
- DEVZONE_COMMAND="devzone uninstall" bash "$uninstaller"
216
+ # The uninstall is the Go program's (#884), as update is: an older devzone
217
+ # keeps its own uninstall.sh, which the Go command runs from its folder
218
+ "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" uninstall "${@:2}"
246
219
  ;;
247
220
  workspace)
248
221
  bash "$PAQUET/manage/workspace.sh" "${@:2}"
@@ -84,10 +84,18 @@ start_workspace() {
84
84
  done
85
85
  image="$repo:$tag"
86
86
  # Argo CD first when wanted (#516): the workspace is then an Application
87
- argocd_ensure
88
- if [ -n "${DEVZONE_FROM_GO:-}" ] && argocd_active; then devzone workspace deploy "$repo" "$tag" "$with_image"; else workspace_deploy "$repo" "$tag" "$with_image"; fi
87
+ if [ "$(grep '^argocd=' .devzone.modules 2>/dev/null | tail -1 | cut -d= -f2-)" != off ]; then
88
+ "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace services enable argocd || echo "⚠ Argo CD not installed: the workspace is deployed with helm directly (devzone workspace services enable argocd to retry)" >&2
89
+ fi
90
+ rc=0
91
+ "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace deploy "$repo" "$tag" "$with_image" || rc=$?
92
+ if [ "$rc" -eq 3 ]; then
93
+ workspace_helm_deploy "$repo" "$tag" "$with_image"
94
+ elif [ "$rc" -ne 0 ]; then
95
+ return "$rc"
96
+ fi
89
97
  # Projects of .argocd.conf held too (#516)
90
- argocd_reconcile || true
98
+ "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace argocd reconcile || true
91
99
  "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace wait "$image" || return 1
92
100
  "${DEVZONE_HOST_BIN:-false}" workspace agents-guard || true
93
101
  "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace ports start
@@ -111,7 +119,7 @@ workspace_helm_deploy() {
111
119
  # Uninstalls the workspace from the cluster (Argo CD Application or helm release).
112
120
  stop_workspace() {
113
121
  "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace ports stop || true
114
- workspace_undeploy
122
+ "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace stop
115
123
  }
116
124
 
117
125
  # Opens a shell in the workspace container.
@@ -120,10 +128,6 @@ shell_workspace() {
120
128
  kubectl $(kubectl_flag) exec -it devzone-workspace-0 --namespace devzone-workspace -c workspace -- bash
121
129
  }
122
130
 
123
- # shellcheck source=manage/scripts/workspace/argocd-workspace.sh
124
- . "$HERE/scripts/workspace/argocd-workspace.sh"
125
- # shellcheck source=manage/scripts/workspace/argocd-services.sh
126
- . "$HERE/scripts/workspace/argocd-services.sh"
127
131
 
128
132
  case "${1:-}" in
129
133
  start) start_workspace "${@:2}" ;;
@@ -133,7 +137,19 @@ case "${1:-}" in
133
137
  shell) shell_workspace ;;
134
138
  ports) "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace ports "${@:2}" ;;
135
139
  services) "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace services "${@:2}" ;;
136
- argocd) argocd_cmd "${@:2}" ;;
140
+ argocd)
141
+ sub="${2:-status}"
142
+ case "$sub" in
143
+ status) "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace argocd status ;;
144
+ init) "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace argocd init "${@:3}" ;;
145
+ apply) "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace argocd apply ;;
146
+ app) "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace argocd app "${@:3}" ;;
147
+ *)
148
+ echo "✖ devzone workspace argocd status | init [--repo <url>|--none] | apply | app add <repo url> [path] [--name N] [--revision R] | app list | app remove <N>" >&2
149
+ exit 1
150
+ ;;
151
+ esac
152
+ ;;
137
153
  egress) "${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" workspace egress "${@:2}" ;;
138
154
  '' | -h | --help | help)
139
155
  echo "devzone workspace start|stop|status|shell|ports|services|argocd|update|egress"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devzone",
3
- "version": "7.5.4",
3
+ "version": "7.6.0",
4
4
  "description": "Ton poste de développement Linux, prêt en une commande, identique sur Mac, Windows et Linux.",
5
5
  "license": "GPL-3.0-only",
6
6
  "repository": {
@@ -1,125 +0,0 @@
1
- #!/usr/bin/env bash
2
- # shellcheck shell=bash
3
- # devzone, module state: read, write, enable, disable (change_module).
4
- # Sourced by .devcontainer/devzone (split of the 1 600 lines file, #722):
5
- # functions only, shared variables are defined in devzone.
6
-
7
- description() {
8
- case "$1" in
9
- ai) echo "AI assistants: Claude Code, opencode" ;;
10
- kubernetes) echo "connection to the host cluster and metrics-server at startup" ;;
11
- gitlab) echo "test GitLab in the services cluster" ;;
12
- postgres) echo "shared PostgreSQL, one database per project" ;;
13
- argocd) echo "Argo CD, deployment interface of the services cluster" ;;
14
- mysql) echo "shared MySQL, one database per project" ;;
15
- esac
16
- }
17
-
18
- is_known() {
19
- local m
20
- for m in "${MODULES[@]}"; do [ "$m" = "$1" ] && return 0; done
21
- return 1
22
- }
23
-
24
- # First start (no state): the state is created by Go state command (#879): old global
25
- # state taken over, backup copy restored, state rebuilt from the services
26
- # cluster, otherwise first installation
27
- init_state() {
28
- DEVZONE_STATE="$ETAT" bash "${ICI:-$(dirname "${BASH_SOURCE[0]}")}/devzone" state init "${MODULES[@]}"
29
- }
30
-
31
- value_of() {
32
- init_state
33
- local v
34
- v="$(grep -E "^$1=" "$ETAT" | tail -1 | cut -d= -f2 || true)"
35
- [ "$v" = on ] && echo on || echo off
36
- }
37
-
38
- # State-file write delegated to Go (#879): lock, backup and atomic replace.
39
- write_value() {
40
- init_state || return 1
41
- DEVZONE_STATE="$ETAT" bash "${ICI:-$(dirname "${BASH_SOURCE[0]}")}/devzone" state write "$1" "$2"
42
- }
43
-
44
- # Removes a key from the state file: the configuration of a service only exists
45
- # while it is chosen (#242)
46
- remove_key() {
47
- init_state || return 1
48
- DEVZONE_STATE="$ETAT" bash "${ICI:-$(dirname "${BASH_SOURCE[0]}")}/devzone" state remove "$1"
49
- }
50
-
51
- # True if the file only holds the $schema key (created by opencode by default)
52
- only_schema_key() {
53
- local others
54
- others="$(grep -vcE '^[[:space:]]*([{}]|"?[$]schema"?[[:space:]]*:.*)?[[:space:]]*$' "$1" || true)"
55
- [ "$others" -eq 0 ] && grep -qF "\$schema" "$1"
56
- }
57
-
58
- # Message for the removed llm module (migration, #669).
59
- llm_removed_msg() {
60
- echo "devzone : llm module removed: devzone no longer hosts a model; the host (Ollama) models are detected instead (devzone ai). To free the disk: kubectl delete namespace devzone-llm"
61
- }
62
-
63
- # Drops the llm= state line when present and reports the removal once (#669).
64
- migrate_llm() {
65
- [ -f "$ETAT" ] || return 0
66
- grep -qE '^llm=' "$ETAT" 2>/dev/null || return 0
67
- DEVZONE_STATE="$ETAT" bash "${ICI:-$(dirname "${BASH_SOURCE[0]}")}/devzone" state remove llm
68
- llm_removed_msg
69
- }
70
-
71
- change_module() {
72
- local m="${2:-}"
73
- if [ -z "$m" ]; then
74
- echo "devzone : unknown module : (none) ; modules : ${MODULES[*]}" >&2
75
- exit 1
76
- fi
77
- # llm removed (#669): migration message, never unknown module.
78
- if [ "$m" = llm ]; then
79
- init_state 2>/dev/null || true
80
- if [ -f "$ETAT" ] && grep -qE '^llm=' "$ETAT" 2>/dev/null; then
81
- DEVZONE_STATE="$ETAT" bash "${ICI:-$(dirname "${BASH_SOURCE[0]}")}/devzone" state remove llm
82
- fi
83
- llm_removed_msg
84
- return 1
85
- fi
86
- migrate_llm
87
- if ! is_known "$m"; then
88
- # An application of the catalog: the line is written, then applied
89
- if [ -f "$ICI/catalog/$m/app.conf" ]; then
90
- write_value "$m" "$1"
91
- DEVZONE_STATE="$ETAT" "$ICI/devzone" catalog apply
92
- return
93
- fi
94
- echo "devzone : unknown module : $m ; modules : ${MODULES[*]}" >&2
95
- exit 1
96
- fi
97
- # In the Kubernetes workspace pod the services are installed from the
98
- # workstation (#528): the pod has no administrator access to the cluster.
99
- # DEVZONE_SERVICES_ADMIN=1: run by services-admin.sh with a temporary one.
100
- if in_pod && service_module "$m" && [ -z "${DEVZONE_SERVICES_ADMIN:-}" ]; then
101
- if [ "$1" = on ]; then
102
- echo "devzone: in the workspace pod, $m is installed from the workstation: devzone workspace services enable $m" >&2
103
- else
104
- echo "devzone: in the workspace pod, $m is removed from the workstation: devzone workspace services disable $m" >&2
105
- fi
106
- return 2
107
- fi
108
- if [ "$1" = off ] && { [ "$m" = postgres ] || [ "$m" = mysql ] || [ "$m" = gitlab ]; }; then
109
- confirm_removal "$m" "${@:3}" || return 0
110
- fi
111
- write_value "$m" "$1"
112
- # Services held by Argo CD (#559): postgres and mysql, plus the release
113
- # of the Applications when argocd is turned off. gitlab has its own path,
114
- # the other modules go straight to their installer (hook exit 3).
115
- if [ "$m" = postgres ] || [ "$m" = mysql ] || { [ "$m" = argocd ] && [ "$1" = off ]; }; then
116
- # 0 done by Argo CD, 3 helm direct as before, else failed
117
- if DEVZONE_STATE="$ETAT" "$ICI/devzone" argocd services-hook "$m" "$1" "${@:3}"; then return 0; elif [ $? -ne 3 ]; then return 1; fi
118
- fi
119
- # The assistant part of enable/disable ai runs in the Go command (#882).
120
- if [ "$m" = ai ]; then
121
- DEVZONE_STATE="$ETAT" "$ICI/devzone" ai apply "$1" "${@:3}"
122
- else
123
- "apply_$m" "$1" "${@:3}"
124
- fi
125
- }
@@ -1,189 +0,0 @@
1
- #!/usr/bin/env bash
2
- # shellcheck shell=bash
3
- # devzone, platform: GitHub or GitLab.
4
- # Sourced by .devcontainer/devzone (split of the 1 600 lines file, #722):
5
- # functions only, shared variables are defined in devzone.
6
-
7
-
8
- # ---- Platform: GitHub (default) or GitLab (#240) ----
9
- # Choice kept in the state file (platform=, gitlab_url=), per instance; the
10
- # configuration of a service only exists while it is chosen (#242): glab and the
11
- # URL disappear when going back to github.
12
-
13
- # Current platform: github when there is no line (default)
14
- platform_read() {
15
- local v
16
- v="$(grep -E '^platform=' "$ETAT" 2>/dev/null | tail -1 | cut -d= -f2 || true)"
17
- [ "$v" = gitlab ] && echo gitlab || echo github
18
- }
19
-
20
- # URL of the GitLab instance, nothing if missing
21
- gitlab_url_read() {
22
- grep -E '^gitlab_url=' "$ETAT" 2>/dev/null | tail -1 | cut -d= -f2- || true
23
- }
24
-
25
- # Host of a URL, without its protocol (glab --hostname)
26
- host_of() {
27
- echo "$1" | sed -E 's#^[a-z]+://##; s#/$##'
28
- }
29
-
30
- # Removes glab and its configuration (back to github)
31
- remove_glab() {
32
- rm -f "$GLAB"
33
- rm -rf "$HOME/.config/glab-cli"
34
- }
35
-
36
- # State line for the platform: github by default, or the GitLab instance with
37
- # its connected glab on the login command otherwise
38
- platform_line() {
39
- local url host
40
- if [ "$(platform_read)" = gitlab ]; then
41
- url="$(gitlab_url_read)"
42
- host="$(host_of "$url")"
43
- if [ -x "$GLAB" ] && "$GLAB" auth status --hostname "$host" >/dev/null 2>&1; then
44
- printf ' ✔ platform gitlab: %s, glab connected\n' "$url"
45
- else
46
- printf ' ⚠ platform gitlab: %s, glab not connected: glab auth login --hostname %s\n' "$url" "$host"
47
- fi
48
- else
49
- echo " ✔ platform github"
50
- fi
51
- }
52
-
53
- # Simple display of the platform (devzone platform)
54
- platform_summary() {
55
- local url host
56
- if [ "$(platform_read)" = gitlab ]; then
57
- url="$(gitlab_url_read)"
58
- host="$(host_of "$url")"
59
- if [ -x "$GLAB" ] && "$GLAB" auth status --hostname "$host" >/dev/null 2>&1; then
60
- echo "devzone : gitlab platform: $url, glab connected"
61
- else
62
- echo "devzone : gitlab platform: $url, glab not connected: glab auth login --hostname $host"
63
- fi
64
- else
65
- echo "devzone : github platform (default)"
66
- fi
67
- }
68
-
69
- # Installs glab (official release, SHA-256 sum checked), nothing if it is
70
- # already there; the binary ends in ~/.local/bin (remove_glab removes it)
71
- install_glab() {
72
- local arch="" sum archive folder glab_tmp
73
- if [ -x "$GLAB" ] && "$GLAB" --version >/dev/null 2>&1; then
74
- return 0
75
- fi
76
- case "$(uname -m)" in
77
- arm64 | aarch64) arch=arm64 sum="$GLAB_SOMME_ARM64" ;;
78
- *) arch=amd64 sum="$GLAB_SOMME_AMD64" ;;
79
- esac
80
- echo "devzone : downloading glab $GLAB_VERSION (SHA-256 checked)…"
81
- archive="$(mktemp)"
82
- if ! curl -fsSL -o "$archive" "https://gitlab.com/gitlab-org/cli/-/releases/$GLAB_VERSION/downloads/glab_${GLAB_VERSION#v}_linux_${arch}.tar.gz"; then
83
- rm -f "$archive"
84
- echo "devzone : glab download failed (official gitlab.com release); retry: devzone platform gitlab --url URL" >&2
85
- return 1
86
- fi
87
- if [ "$(sha256sum "$archive" | cut -d' ' -f1)" != "$sum" ]; then
88
- rm -f "$archive"
89
- echo "devzone : glab SHA-256 sum unexpected, aborting; archive refused" >&2
90
- return 1
91
- fi
92
- folder="$(mktemp -d)"
93
- glab_tmp="$folder/bin/glab"
94
- if ! tar -xzf "$archive" -C "$folder" || [ ! -f "$glab_tmp" ]; then
95
- glab_tmp="$folder/glab"
96
- fi
97
- if [ ! -f "$glab_tmp" ]; then
98
- rm -rf "$folder" "$archive"
99
- echo "devzone : glab binary missing from the archive, aborting" >&2
100
- return 1
101
- fi
102
- mkdir -p "$HOME/.local/bin"
103
- mv "$glab_tmp" "$GLAB"
104
- chmod +x "$GLAB"
105
- rm -rf "$folder" "$archive"
106
- }
107
-
108
- # Login to the GitLab instance: instance of the gitlab module -> root token of
109
- # the module (http protocol, never shown); another instance -> interactive, a
110
- # browser asking for the login code. Checks: exit code of the auth login, then
111
- # auth status --hostname; without that check, not "connected".
112
- connect_glab() {
113
- local host="$1" url="$2" token
114
- if [ "$url" = "$GITLAB_URL_MODULE" ]; then
115
- if [ ! -f "$RACINE/workspace/.gitlab/root-token" ]; then
116
- echo "devzone : root token of the gitlab module not found ($RACINE/workspace/.gitlab/root-token): devzone enable gitlab, or by hand: glab auth login --hostname $host" >&2
117
- return 1
118
- fi
119
- token="$(cat "$RACINE/workspace/.gitlab/root-token")"
120
- if ! "$GLAB" auth login --hostname "$host" --api-protocol http --git-protocol http --token "$token"; then
121
- echo "devzone : cannot connect to the gitlab instance: devzone enable gitlab, or by hand: glab auth login --hostname $host" >&2
122
- return 1
123
- fi
124
- elif ! "$GLAB" auth login --hostname "$host"; then
125
- echo "devzone : cannot connect to the gitlab instance: glab auth login --hostname $host" >&2
126
- return 1
127
- fi
128
- if ! "$GLAB" auth status --hostname "$host" >/dev/null 2>&1; then
129
- echo "devzone : cannot verify the connection: glab auth status --hostname $host" >&2
130
- return 1
131
- fi
132
- }
133
-
134
- # Changes the platform: github (default, current behaviour) or gitlab
135
- change_platform() {
136
- local target="${1:-}" url="" expect="" arg host
137
- case "$target" in
138
- github)
139
- # Removes the credential setting of the last gitlab host, if there is one
140
- if [ -n "$(gitlab_url_read)" ]; then
141
- git config --global --unset-all "credential.$(gitlab_url_read).helper" 2>/dev/null || true
142
- fi
143
- remove_glab
144
- remove_key platform
145
- remove_key gitlab_url
146
- echo "devzone : github platform (default): gh checks; glab and its configuration removed if they were installed"
147
- ;;
148
- gitlab)
149
- for arg in "${@:2}"; do
150
- if [ -n "$expect" ]; then url="$arg"; expect=""; continue; fi
151
- case "$arg" in
152
- --url) expect=1 ;;
153
- *) echo "devzone : unknown argument: $arg (devzone platform gitlab --url URL)" >&2; return 1 ;;
154
- esac
155
- done
156
- if [ -n "$expect" ]; then
157
- echo "devzone : --url expects a URL" >&2
158
- return 1
159
- fi
160
- if [ -z "$url" ]; then
161
- if [ "$(value_of gitlab)" = on ]; then
162
- url="$GITLAB_URL_MODULE"
163
- else
164
- echo "devzone : missing URL: devzone platform gitlab --url URL (or an active gitlab module for the local instance)" >&2
165
- return 1
166
- fi
167
- fi
168
- host="$(host_of "$url")"
169
- if ! install_glab; then
170
- return 1
171
- fi
172
- if ! connect_glab "$host" "$url"; then
173
- echo "devzone : reconnect needed: glab auth login --hostname $host" >&2
174
- return 1
175
- fi
176
- if ! git config --global "credential.$url.helper" "!$GLAB auth git-credential"; then
177
- echo "devzone : cannot set the git credential" >&2
178
- return 1
179
- fi
180
- write_value platform gitlab
181
- write_value gitlab_url "$url"
182
- echo "devzone : gitlab platform: $url, glab connected"
183
- ;;
184
- *)
185
- echo "devzone : unknown platform: ${target:-(none)}; choices: github (default) or gitlab [--url URL]" >&2
186
- return 1
187
- ;;
188
- esac
189
- }