devzone 7.5.5 → 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.
- package/.devcontainer/devzone +1 -52
- package/bin/SHA256SUMS +6 -6
- package/bin/devzone-darwin-amd64 +0 -0
- package/bin/devzone-darwin-arm64 +0 -0
- package/bin/devzone-linux-amd64 +0 -0
- package/bin/devzone-linux-arm64 +0 -0
- package/bin/devzone-windows-amd64.exe +0 -0
- package/bin/devzone-windows-arm64.exe +0 -0
- package/manage/devzone +7 -16
- package/package.json +1 -1
- package/.devcontainer/devzone-modules.sh +0 -125
- package/.devcontainer/devzone-platform.sh +0 -189
- package/.devcontainer/devzone-services.sh +0 -242
- package/manage/scripts/uninstall.sh +0 -234
package/.devcontainer/devzone
CHANGED
|
@@ -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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
package/bin/devzone-darwin-amd64
CHANGED
|
Binary file
|
package/bin/devzone-darwin-arm64
CHANGED
|
Binary file
|
package/bin/devzone-linux-amd64
CHANGED
|
Binary file
|
package/bin/devzone-linux-arm64
CHANGED
|
Binary file
|
|
Binary file
|
|
Binary file
|
package/manage/devzone
CHANGED
|
@@ -171,9 +171,10 @@ devzone $(version): development workspace in a Kubernetes cluster
|
|
|
171
171
|
the installed package, after backing up the replaced files in
|
|
172
172
|
.devzone.backup/ (the new image is used at the next workspace start)
|
|
173
173
|
devzone uninstall [--yes]
|
|
174
|
-
in a devzone folder: removes
|
|
175
|
-
|
|
176
|
-
|
|
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
|
|
177
178
|
devzone ai [check|rapport|guard] host models, update report or tool-call guard
|
|
178
179
|
devzone workspace start|stop|status|shell|update|deploy
|
|
179
180
|
devzone workspace vscode|copy-to|copy-from|clone
|
|
@@ -212,19 +213,9 @@ case "${1:-}" in
|
|
|
212
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}"
|
|
213
214
|
;;
|
|
214
215
|
uninstall)
|
|
215
|
-
#
|
|
216
|
-
#
|
|
217
|
-
|
|
218
|
-
if [ -d .devcontainer ]; then
|
|
219
|
-
for f in manage/scripts/uninstall.sh core/scripts/uninstall.sh scripts/uninstall.sh uninstall.sh; do
|
|
220
|
-
if [ -f "$f" ]; then uninstaller="$f" && break; fi
|
|
221
|
-
done
|
|
222
|
-
fi
|
|
223
|
-
if [ -z "$uninstaller" ]; then
|
|
224
|
-
echo "✖ Run this in a devzone folder (uninstall.sh not found here)." >&2
|
|
225
|
-
exit 1
|
|
226
|
-
fi
|
|
227
|
-
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}"
|
|
228
219
|
;;
|
|
229
220
|
workspace)
|
|
230
221
|
bash "$PAQUET/manage/workspace.sh" "${@:2}"
|
package/package.json
CHANGED
|
@@ -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
|
-
}
|
|
@@ -1,242 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# shellcheck shell=bash
|
|
3
|
-
# devzone, services of the cluster and their apply functions.
|
|
4
|
-
# Sourced by .devcontainer/devzone (split of the 1 600 lines file, #722):
|
|
5
|
-
# functions only, shared variables are defined in devzone.
|
|
6
|
-
|
|
7
|
-
# Runs a long command, writing "still running" every DEVZONE_PROGRESS s on
|
|
8
|
-
# stderr: a silent installation looks blocked (#195)
|
|
9
|
-
with_progress() {
|
|
10
|
-
local step="${DEVZONE_PROGRESS:-30}" elapsed=0 pid code=0
|
|
11
|
-
"$@" &
|
|
12
|
-
pid=$!
|
|
13
|
-
while kill -0 "$pid" 2>/dev/null; do
|
|
14
|
-
sleep 1
|
|
15
|
-
elapsed=$((elapsed + 1))
|
|
16
|
-
if [ $((elapsed % step)) -eq 0 ] && kill -0 "$pid" 2>/dev/null; then
|
|
17
|
-
echo "devzone : … still running (${elapsed} s)" >&2
|
|
18
|
-
fi
|
|
19
|
-
done
|
|
20
|
-
wait "$pid" || code=$?
|
|
21
|
-
return "$code"
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
# File that marks an active module in failure (content: where to look); next to
|
|
25
|
-
# the state, in its volume: the state shows it at each startup
|
|
26
|
-
failure_marker_file() {
|
|
27
|
-
echo "$ETAT-failed-$1"
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
# Services in the Kubernetes workspace pod (#528): gitlab, postgres and argocd
|
|
31
|
-
# live in the cluster, installed from the workstation (devzone workspace
|
|
32
|
-
# services). The pod has no kubeconfig and a limited account (#430): their
|
|
33
|
-
# presence is the cluster DNS (like #515), never an installer failure marker.
|
|
34
|
-
in_pod() {
|
|
35
|
-
[ "${DEVZONE_WORKSPACE:-}" = kubernetes ]
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
service_module() {
|
|
39
|
-
case "$1" in
|
|
40
|
-
gitlab | postgres | argocd) return 0 ;;
|
|
41
|
-
esac
|
|
42
|
-
return 1
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
# DNS name of the service of a module: <service>.<namespace>.svc
|
|
46
|
-
service_dns() {
|
|
47
|
-
case "$1" in
|
|
48
|
-
gitlab) echo "gitlab-webservice-default.devzone-gitlab${INSTANCE_SUFFIX}.svc" ;;
|
|
49
|
-
postgres) echo "postgres.devzone-postgres.svc" ;;
|
|
50
|
-
argocd) echo "argocd-server.devzone-argocd.svc" ;;
|
|
51
|
-
esac
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
service_present() {
|
|
55
|
-
getent hosts "$(service_dns "$1")" >/dev/null 2>&1
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
# Status line of a service module in the pod: present → active; absent → the
|
|
59
|
-
# workstation command that installs it
|
|
60
|
-
service_pod_line() {
|
|
61
|
-
local m="$1"
|
|
62
|
-
if service_present "$m"; then
|
|
63
|
-
printf ' ✔ module %-10s active: %s (%s)\n' "$m" "$(description "$m")" "$(service_dns "$m")"
|
|
64
|
-
elif [ "$(value_of "$m")" = on ]; then
|
|
65
|
-
printf ' ⚠ module %-10s not in the cluster: on the workstation, devzone workspace services enable %s\n' "$m" "$m"
|
|
66
|
-
else
|
|
67
|
-
printf ' ○ module %-10s optional, %s: on the workstation, devzone workspace services enable %s\n' "$m" "$(description "$m")" "$m"
|
|
68
|
-
fi
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
# devzone apply of a service module: in the Kubernetes workspace pod nothing
|
|
72
|
-
# is installed (the workstation does it, #528) and the failure marker of an
|
|
73
|
-
# earlier start is cleared; elsewhere, the installer of the module
|
|
74
|
-
apply_service() {
|
|
75
|
-
if in_pod; then
|
|
76
|
-
rm -f "$(failure_marker_file "$1")"
|
|
77
|
-
echo "devzone: $1 is installed from the workstation (devzone workspace services enable $1): nothing to do in the pod"
|
|
78
|
-
return 0
|
|
79
|
-
fi
|
|
80
|
-
"apply_$1" on
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
apply_kubernetes() {
|
|
84
|
-
if [ "$1" = on ]; then
|
|
85
|
-
# Clusters are connected from the workstation; no script to run here.
|
|
86
|
-
return 0
|
|
87
|
-
else
|
|
88
|
-
rm -f "$HOME/.kube/hote.config"
|
|
89
|
-
# metrics-server removed from the clusters where devzone installed it
|
|
90
|
-
# (devzone=installe marker set by the Go command); via its subcommand
|
|
91
|
-
"$ICI/devzone" metrics remove || true
|
|
92
|
-
echo "devzone : kubernetes disabled"
|
|
93
|
-
fi
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
apply_gitlab() {
|
|
97
|
-
local current_state
|
|
98
|
-
if [ "$1" = on ]; then
|
|
99
|
-
# Skip if the state is ready and the runner online; otherwise install resumes
|
|
100
|
-
current_state="$("$ICI/devzone" gitlab status)"
|
|
101
|
-
if [[ "$current_state" == *"ready"* && "$current_state" == *"runner online"* ]]; then
|
|
102
|
-
echo "devzone : gitlab already active, nothing to do."
|
|
103
|
-
# /etc/hosts regenerated by Docker: gitlab.localhost is set again here too
|
|
104
|
-
"$ICI/devzone" gitlab host-set
|
|
105
|
-
# Failure of an old run cleared: gitlab is ready (#366)
|
|
106
|
-
rm -f "$(failure_marker_file gitlab)"
|
|
107
|
-
else
|
|
108
|
-
echo "devzone : activating gitlab via its installer…"
|
|
109
|
-
if ! "$ICI/devzone" gitlab install; then
|
|
110
|
-
echo "gitlab" > "$(failure_marker_file gitlab)"
|
|
111
|
-
return 1
|
|
112
|
-
fi
|
|
113
|
-
rm -f "$(failure_marker_file gitlab)"
|
|
114
|
-
fi
|
|
115
|
-
else
|
|
116
|
-
# Disable gitlab only if its namespace still exists
|
|
117
|
-
if "$ICI/devzone" gitlab installed; then
|
|
118
|
-
echo "devzone : deactivating gitlab…"
|
|
119
|
-
if [ -n "${DELETE_DATA:-}" ]; then
|
|
120
|
-
"$ICI/devzone" gitlab uninstall --yes
|
|
121
|
-
else
|
|
122
|
-
"$ICI/devzone" gitlab uninstall
|
|
123
|
-
fi
|
|
124
|
-
else
|
|
125
|
-
echo "devzone : gitlab already deactivated (no devzone-gitlab namespace)."
|
|
126
|
-
fi
|
|
127
|
-
fi
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
# Shared PostgreSQL (#280): installed on the devzone cluster, chosen at the
|
|
131
|
-
# first activation (--context, terminal menu, dedicated kind otherwise)
|
|
132
|
-
apply_postgres() {
|
|
133
|
-
local wanted="" confirm_ctx="" expect="" arg ctx actual current_state
|
|
134
|
-
if [ "$1" = on ]; then
|
|
135
|
-
for arg in "${@:2}"; do
|
|
136
|
-
if [ -n "$expect" ]; then
|
|
137
|
-
case "$expect" in
|
|
138
|
-
context) wanted="$arg" ;;
|
|
139
|
-
confirm) confirm_ctx="$arg" ;;
|
|
140
|
-
esac
|
|
141
|
-
expect=""
|
|
142
|
-
continue
|
|
143
|
-
fi
|
|
144
|
-
case "$arg" in
|
|
145
|
-
--context) expect=context ;;
|
|
146
|
-
--confirm) expect=confirm ;;
|
|
147
|
-
*) echo "devzone : unknown argument: $arg (devzone enable postgres --context CTX [--confirm CTX])" >&2; write_value postgres off; return 2 ;;
|
|
148
|
-
esac
|
|
149
|
-
done
|
|
150
|
-
if [ -n "$expect" ]; then
|
|
151
|
-
echo "devzone : $expect expects a context" >&2
|
|
152
|
-
write_value postgres off
|
|
153
|
-
return 2
|
|
154
|
-
fi
|
|
155
|
-
actual="$("$ICI/devzone" kube saved)"
|
|
156
|
-
if [ -n "$wanted" ] && [ -n "$actual" ] && [ "$wanted" != "$actual" ]; then
|
|
157
|
-
echo "devzone : devzone services are on $actual; to change: devzone cluster $wanted" >&2
|
|
158
|
-
write_value postgres off
|
|
159
|
-
return 2
|
|
160
|
-
fi
|
|
161
|
-
if [ -n "$confirm_ctx" ]; then
|
|
162
|
-
ctx="$("$ICI/devzone" kube choose "$wanted" --confirm "$confirm_ctx")" || { write_value postgres off; return 2; }
|
|
163
|
-
else
|
|
164
|
-
ctx="$("$ICI/devzone" kube choose "$wanted")" || { write_value postgres off; return 2; }
|
|
165
|
-
fi
|
|
166
|
-
# Choice kept before the installation: a resume targets the same cluster
|
|
167
|
-
"$ICI/devzone" kube save "$ctx"
|
|
168
|
-
current_state="$("$ICI/devzone" postgres status)"
|
|
169
|
-
# "relay stopped" first: this line also starts with "ready on"
|
|
170
|
-
if [[ "$current_state" == *"relay stopped"* ]]; then
|
|
171
|
-
"$ICI/devzone" postgres relay-start
|
|
172
|
-
echo "devzone : postgres : relay restarted"
|
|
173
|
-
elif [[ "$current_state" == "ready on"* ]]; then
|
|
174
|
-
echo "devzone : postgres already active, nothing to do."
|
|
175
|
-
elif ! "$ICI/devzone" postgres install; then
|
|
176
|
-
echo "postgres" >"$(failure_marker_file postgres)"
|
|
177
|
-
return 1
|
|
178
|
-
fi
|
|
179
|
-
rm -f "$(failure_marker_file postgres)"
|
|
180
|
-
else
|
|
181
|
-
"$ICI/devzone" postgres uninstall
|
|
182
|
-
rm -f "$(failure_marker_file postgres)"
|
|
183
|
-
fi
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
# Argo CD (#411): installed in the services cluster, access through the relay
|
|
187
|
-
# 127.0.0.1:8443; a failure is marked in the state and resumed by devzone apply
|
|
188
|
-
apply_argocd() {
|
|
189
|
-
local current_state
|
|
190
|
-
if [ "$1" = on ]; then
|
|
191
|
-
current_state="$("$ICI/devzone" argocd status)"
|
|
192
|
-
# "relay stopped" first: this line also starts with "ready"
|
|
193
|
-
if [[ "$current_state" == *"relay stopped"* ]]; then
|
|
194
|
-
"$ICI/devzone" argocd relay-start
|
|
195
|
-
echo "devzone : argocd : relay restarted"
|
|
196
|
-
elif [[ "$current_state" == "ready"* ]]; then
|
|
197
|
-
echo "devzone : argocd already active, nothing to do."
|
|
198
|
-
elif ! "$ICI/devzone" argocd install; then
|
|
199
|
-
echo "argocd" >"$(failure_marker_file argocd)"
|
|
200
|
-
return 1
|
|
201
|
-
fi
|
|
202
|
-
rm -f "$(failure_marker_file argocd)"
|
|
203
|
-
else
|
|
204
|
-
"$ICI/devzone" argocd uninstall
|
|
205
|
-
rm -f "$(failure_marker_file argocd)"
|
|
206
|
-
fi
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
# Catalog MySQL (#414): same logic as postgres (relay restarted if stopped),
|
|
210
|
-
# installation delegated to the Go module
|
|
211
|
-
apply_mysql() {
|
|
212
|
-
local current_state ctx
|
|
213
|
-
if [ "$1" = on ]; then
|
|
214
|
-
ctx="$(cluster_saved)"
|
|
215
|
-
if [ -z "$ctx" ]; then
|
|
216
|
-
echo "devzone : mysql: no cluster chosen: devzone enable mysql" >&2
|
|
217
|
-
write_value mysql off
|
|
218
|
-
echo mysql >"$(failure_marker_file mysql)"
|
|
219
|
-
return 2
|
|
220
|
-
fi
|
|
221
|
-
current_state="$("$ICI/devzone" mysql status)"
|
|
222
|
-
# "relay stopped" first: this line also starts with "ready on"
|
|
223
|
-
if [[ "$current_state" == *"relay stopped"* ]]; then
|
|
224
|
-
"$ICI/devzone" mysql relay-start
|
|
225
|
-
echo "devzone : mysql: relay restarted"
|
|
226
|
-
elif [[ "$current_state" == "ready on"* ]]; then
|
|
227
|
-
echo "devzone : mysql already active, nothing to do."
|
|
228
|
-
elif ! "$ICI/devzone" mysql install; then
|
|
229
|
-
echo mysql >"$(failure_marker_file mysql)"
|
|
230
|
-
return 1
|
|
231
|
-
fi
|
|
232
|
-
rm -f "$(failure_marker_file mysql)"
|
|
233
|
-
else
|
|
234
|
-
# Removal without deleting the data: volume kept (#441); the databases
|
|
235
|
-
# only leave with a yes (confirm_removal)
|
|
236
|
-
DEVZONE_STATE="$ETAT" "$ICI/devzone" catalog remove mysql
|
|
237
|
-
if [ -n "${DELETE_DATA:-}" ]; then
|
|
238
|
-
"$ICI/devzone" mysql delete-data --yes
|
|
239
|
-
fi
|
|
240
|
-
rm -f "$(failure_marker_file mysql)"
|
|
241
|
-
fi
|
|
242
|
-
}
|
|
@@ -1,234 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Full devzone uninstall, run on the host:
|
|
3
|
-
# make desinstaller everything, after confirmation
|
|
4
|
-
# make desinstaller KEEP=logins everything except logins (gh, git,
|
|
5
|
-
# Claude Code, opencode, modules)
|
|
6
|
-
# Removes: container, image, kind clusters of the instance and containers
|
|
7
|
-
# labeled devzone.instance on the host Docker (#291), former internal Docker
|
|
8
|
-
# volume (installs before #291), devzone-* volumes, metrics-server installed by
|
|
9
|
-
# devzone on host local clusters, namespace of devzone services (postgres
|
|
10
|
-
# module) on the chosen host cluster. Never touches: workspace/ (your projects),
|
|
11
|
-
# the base image, a metrics-server not installed by devzone.
|
|
12
|
-
# Without a terminal: CONFIRM=yes.
|
|
13
|
-
set -euo pipefail
|
|
14
|
-
|
|
15
|
-
# devzone folder: two levels above the script (manage/scripts/), so the command
|
|
16
|
-
# works when run from any folder
|
|
17
|
-
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
18
|
-
STATE="$HERE/.devzone.state"
|
|
19
|
-
KEEP="${KEEP:-${GARDER:-}}"
|
|
20
|
-
LOGINS=(gh git claude opencode-config opencode-data config)
|
|
21
|
-
LOCAL_CTX='^(kind-.*|docker-desktop|rancher-desktop|orbstack|minikube)$'
|
|
22
|
-
|
|
23
|
-
case "$KEEP" in "" | logins | connexions) ;; *)
|
|
24
|
-
echo "KEEP: unknown value: $KEEP (only value: logins)" >&2
|
|
25
|
-
exit 1
|
|
26
|
-
;;
|
|
27
|
-
esac
|
|
28
|
-
|
|
29
|
-
# Host engine first: without it every call would show its raw error. The check
|
|
30
|
-
# is the Go program's (#884), found through DEVZONE_HOST_BIN, exported by manage/devzone
|
|
31
|
-
"${DEVZONE_HOST_BIN:?devzone: Go program not found (DEVZONE_HOST_BIN), run it through manage/devzone}" host-check "${DEVZONE_COMMAND:-make desinstaller}" || exit 1
|
|
32
|
-
|
|
33
|
-
# .argocd.conf of the devzone folder: the GitOps repository is never removed
|
|
34
|
-
# with the devzone, only its designation can be changed later
|
|
35
|
-
# shellcheck disable=SC2034 # read by conf.sh
|
|
36
|
-
ARGOCD_CONF="$HERE/.argocd.conf"
|
|
37
|
-
# shellcheck source=SCRIPTDIR/../.devcontainer/argocd/conf.sh
|
|
38
|
-
# shellcheck disable=SC1091
|
|
39
|
-
. "$HERE/.devcontainer/argocd/conf.sh"
|
|
40
|
-
|
|
41
|
-
# Instance name: an instance name may contain a dash (my-devzone),
|
|
42
|
-
# so DEVZONE_VOLUMES is never split
|
|
43
|
-
DEVZONE_INSTANCE="${DEVZONE_VOLUMES:-devzone}"
|
|
44
|
-
INSTANCE_SUFFIX=""
|
|
45
|
-
if [ "$DEVZONE_INSTANCE" != "devzone" ]; then
|
|
46
|
-
INSTANCE_SUFFIX="-${DEVZONE_INSTANCE}"
|
|
47
|
-
fi
|
|
48
|
-
|
|
49
|
-
# Run INSIDE the container, docker talks to host Docker (#291): volumes, images
|
|
50
|
-
# and containers seen are those of the workstation, and the host instance name
|
|
51
|
-
# (DEVZONE_VOLUMES) is unknown here. Touching Docker from the container could
|
|
52
|
-
# remove another instance's resources (or the default instance): only the
|
|
53
|
-
# Kubernetes part is handled.
|
|
54
|
-
# DEVZONE_IN_CONTAINER=yes|no forces the mode (tests, which run inside a container)
|
|
55
|
-
case "${DEVZONE_IN_CONTAINER:-}" in
|
|
56
|
-
yes) INSIDE_CONTAINER=true ;;
|
|
57
|
-
no) INSIDE_CONTAINER=false ;;
|
|
58
|
-
*) INSIDE_CONTAINER=false; [ ! -f /.dockerenv ] || INSIDE_CONTAINER=true ;;
|
|
59
|
-
esac
|
|
60
|
-
|
|
61
|
-
# --- Inventory ---------------------------------------------------------------
|
|
62
|
-
echo "▶ Inventory (folder $HERE)"
|
|
63
|
-
containers=() images=() dind=() volumes=() kept=()
|
|
64
|
-
kind_containers="" labeled_containers=""
|
|
65
|
-
if [ "$INSIDE_CONTAINER" = true ]; then
|
|
66
|
-
echo "ℹ Inside the container: only metrics-server and devzone services are handled."
|
|
67
|
-
echo " Container, image, volumes and kind clusters: make desinstaller on your machine."
|
|
68
|
-
else
|
|
69
|
-
# Label set with the path as opened (VS Code, make): logical or physical path
|
|
70
|
-
# depending on symlinks; both are searched
|
|
71
|
-
ids="$(for path in "$HERE" "$(cd "$HERE" && pwd -P)"; do docker ps -aq --filter "label=devcontainer.local_folder=$path" 2>/dev/null || true; done | sort -u)"
|
|
72
|
-
for id in ${ids}; do
|
|
73
|
-
containers+=("$id")
|
|
74
|
-
images+=("$(docker inspect "$id" --format '{{.Config.Image}}')")
|
|
75
|
-
v="$(docker inspect "$id" --format '{{range .Mounts}}{{if eq .Destination "/var/lib/docker"}}{{.Name}}{{end}}{{end}}')"
|
|
76
|
-
[ -z "$v" ] || dind+=("$v")
|
|
77
|
-
done
|
|
78
|
-
# Container already removed: image and internal Docker noted then
|
|
79
|
-
if [ "${#containers[@]}" -eq 0 ] && [ -f "$STATE" ]; then
|
|
80
|
-
# Read only, never executed
|
|
81
|
-
IMAGE="$(sed -n 's/^IMAGE=//p' "$STATE")"
|
|
82
|
-
DIND="$(sed -n 's/^DIND=//p' "$STATE")"
|
|
83
|
-
[ -z "${IMAGE:-}" ] || ! docker image inspect "$IMAGE" >/dev/null 2>&1 || images+=("$IMAGE")
|
|
84
|
-
[ -z "${DIND:-}" ] || ! docker volume inspect "$DIND" >/dev/null 2>&1 || dind+=("$DIND")
|
|
85
|
-
fi
|
|
86
|
-
|
|
87
|
-
# Containers of the instance kind clusters on host Docker: a kind cluster is
|
|
88
|
-
# nothing more than containers carrying this label
|
|
89
|
-
kind_containers_devzone="$(docker ps -aq --filter "label=io.x-k8s.kind.cluster=devzone${INSTANCE_SUFFIX}" 2>/dev/null | sort -u)"
|
|
90
|
-
kind_containers_gitlab="$(docker ps -aq --filter "label=io.x-k8s.kind.cluster=gitlab${INSTANCE_SUFFIX}" 2>/dev/null | sort -u)"
|
|
91
|
-
kind_containers="${kind_containers_devzone} ${kind_containers_gitlab}"
|
|
92
|
-
kind_containers="${kind_containers# }"
|
|
93
|
-
kind_containers="${kind_containers% }"
|
|
94
|
-
|
|
95
|
-
# Containers carrying label devzone.instance=<instance>
|
|
96
|
-
labeled_containers="$(docker ps -aq --filter "label=devzone.instance=$DEVZONE_INSTANCE" 2>/dev/null | sort -u)"
|
|
97
|
-
|
|
98
|
-
# Volumes: exact names from devcontainer.json (including DEVZONE_VOLUMES prefix)
|
|
99
|
-
config="$(npx -y @devcontainers/cli read-configuration --workspace-folder "$HERE" 2>/dev/null)" || {
|
|
100
|
-
echo "✖ cannot read .devcontainer/devcontainer.json (npx @devcontainers/cli)" >&2
|
|
101
|
-
exit 1
|
|
102
|
-
}
|
|
103
|
-
# shellcheck disable=SC2016 # ${m.source}: JavaScript template, not shell
|
|
104
|
-
for name in $(node -e '
|
|
105
|
-
const c = JSON.parse(require("fs").readFileSync(0, "utf8")).configuration;
|
|
106
|
-
for (const m of c.mounts || []) {
|
|
107
|
-
const s = typeof m === "string" ? m : `source=${m.source},type=${m.type}`;
|
|
108
|
-
if (/type=volume/.test(s)) { const r = /source=([^,]+)/.exec(s); if (r) console.log(r[1]); }
|
|
109
|
-
}' <<<"$config"); do
|
|
110
|
-
docker volume inspect "$name" >/dev/null 2>&1 || continue
|
|
111
|
-
keep=false
|
|
112
|
-
if [ "$KEEP" = logins ] || [ "$KEEP" = connexions ]; then
|
|
113
|
-
for c in "${LOGINS[@]}"; do [[ "$name" == *-"$c" ]] && keep=true; done
|
|
114
|
-
fi
|
|
115
|
-
if [ "$keep" = true ]; then kept+=("$name"); else volumes+=("$name"); fi
|
|
116
|
-
done
|
|
117
|
-
fi
|
|
118
|
-
|
|
119
|
-
# metrics-server installed by devzone (label devzone=installed), on reachable
|
|
120
|
-
# host local clusters; never another one
|
|
121
|
-
metrics=() foreign=()
|
|
122
|
-
if command -v kubectl >/dev/null 2>&1; then
|
|
123
|
-
for ctx in $(kubectl config get-contexts -o name 2>/dev/null | grep -E "$LOCAL_CTX" || true); do
|
|
124
|
-
k=(kubectl --context "$ctx" --request-timeout=5s)
|
|
125
|
-
"${k[@]}" get --raw /readyz >/dev/null 2>&1 || continue
|
|
126
|
-
mark="$("${k[@]}" -n kube-system get deployment metrics-server -o jsonpath='{.metadata.labels.devzone}' 2>/dev/null)" || continue
|
|
127
|
-
if [ "$mark" = installe ] || [ "$mark" = installed ]; then metrics+=("$ctx"); else foreign+=("$ctx"); fi
|
|
128
|
-
done
|
|
129
|
-
fi
|
|
130
|
-
|
|
131
|
-
# devzone services (postgres module, #280) on a host cluster: the namespace it
|
|
132
|
-
# created (label managed-by=devzone). On the dedicated kind, they go with that
|
|
133
|
-
# cluster (removed below). Read only, never executed.
|
|
134
|
-
services=()
|
|
135
|
-
CLUSTER="$(sed -n 's/^cluster=//p' "$HERE/.devzone.modules" 2>/dev/null | tail -1 || true)"
|
|
136
|
-
if [ -n "$CLUSTER" ] && [[ "$CLUSTER" != kind-* ]] && command -v kubectl >/dev/null 2>&1; then
|
|
137
|
-
for ns in $(kubectl --context "$CLUSTER" --request-timeout=5s get namespaces -l app.kubernetes.io/managed-by=devzone -o name 2>/dev/null || true); do
|
|
138
|
-
services+=("${ns#namespace/}")
|
|
139
|
-
done
|
|
140
|
-
fi
|
|
141
|
-
|
|
142
|
-
# --- Confirmation ------------------------------------------------------------
|
|
143
|
-
show_list() { if [ "$#" -eq 0 ]; then echo " (none)"; else printf ' %s\n' "$@"; fi; }
|
|
144
|
-
echo "To remove:"
|
|
145
|
-
echo " container(s):"; show_list ${containers[@]+"${containers[@]}"}
|
|
146
|
-
echo " image(s):"; show_list ${images[@]+"${images[@]}"}
|
|
147
|
-
echo " former internal Docker (installs before #291):"; show_list ${dind[@]+"${dind[@]}"}
|
|
148
|
-
echo " volumes:"; show_list ${volumes[@]+"${volumes[@]}"}
|
|
149
|
-
echo " metrics-server installed by devzone on:"; show_list ${metrics[@]+"${metrics[@]}"}
|
|
150
|
-
echo " devzone services (including postgres databases) on ${CLUSTER:-no cluster}:"; show_list ${services[@]+"${services[@]}"}
|
|
151
|
-
echo " kind clusters of the instance on host Docker:"
|
|
152
|
-
# shellcheck disable=SC2086
|
|
153
|
-
show_list ${kind_containers}
|
|
154
|
-
echo " containers labeled devzone.instance=$DEVZONE_INSTANCE:"
|
|
155
|
-
# shellcheck disable=SC2086
|
|
156
|
-
show_list ${labeled_containers}
|
|
157
|
-
[ "${#kept[@]}" -eq 0 ] || { echo "Kept (KEEP=logins):"; printf ' %s\n' "${kept[@]}"; }
|
|
158
|
-
if [ "$INSIDE_CONTAINER" = false ] && [ "${#containers[@]}" -eq 0 ] && [ ! -f "$STATE" ] && [ "${#images[@]}" -eq 0 ]; then
|
|
159
|
-
echo "ℹ No container and no image trace: if an older removal left them,"
|
|
160
|
-
echo " find them with: docker images 'vsc-$(basename "$HERE")-*' ; docker volume ls -q -f name=dind-var-lib-docker"
|
|
161
|
-
fi
|
|
162
|
-
|
|
163
|
-
nb_ck=0; for _ in ${kind_containers}; do nb_ck=$((nb_ck + 1)); done
|
|
164
|
-
nb_ce=0; for _ in ${labeled_containers}; do nb_ce=$((nb_ce + 1)); done
|
|
165
|
-
total=$((${#containers[@]} + ${#images[@]} + ${#dind[@]} + ${#volumes[@]} + ${#metrics[@]} + ${#services[@]} + nb_ck + nb_ce))
|
|
166
|
-
if [ "$total" -eq 0 ]; then
|
|
167
|
-
echo "✔ Nothing to remove."
|
|
168
|
-
else
|
|
169
|
-
CONFIRM_VALUE="${CONFIRM:-${CONFIRMER:-}}"
|
|
170
|
-
if [ "$CONFIRM_VALUE" != yes ]; then
|
|
171
|
-
if [ ! -t 0 ]; then
|
|
172
|
-
echo "✖ Cannot confirm without a terminal: CONFIRM=yes make desinstaller" >&2
|
|
173
|
-
exit 1
|
|
174
|
-
fi
|
|
175
|
-
read -r -p "Permanently remove? Type yes: " answer
|
|
176
|
-
case "$answer" in
|
|
177
|
-
yes) ;;
|
|
178
|
-
*) echo "Canceled: nothing was removed."; exit 0 ;;
|
|
179
|
-
esac
|
|
180
|
-
fi
|
|
181
|
-
|
|
182
|
-
# --- Removal -------------------------------------------------------------
|
|
183
|
-
for id in ${containers[@]+"${containers[@]}"}; do docker rm -f "$id" >/dev/null && echo "✔ container removed: $id"; done
|
|
184
|
-
for i in ${images[@]+"${images[@]}"}; do docker rmi "$i" >/dev/null && echo "✔ image removed: $i"; done
|
|
185
|
-
for v in ${dind[@]+"${dind[@]}"} ${volumes[@]+"${volumes[@]}"}; do docker volume rm "$v" >/dev/null && echo "✔ volume removed: $v"; done
|
|
186
|
-
if [ "${#metrics[@]}" -gt 0 ]; then
|
|
187
|
-
version="$(sed -n 's/^METRICS_SERVER_VERSION=//p' "$HERE/.devcontainer/versions.env" | head -1)"
|
|
188
|
-
manifest="https://github.com/kubernetes-sigs/metrics-server/releases/download/${version}/components.yaml"
|
|
189
|
-
for ctx in "${metrics[@]}"; do
|
|
190
|
-
kubectl --context "$ctx" delete -f "$manifest" --ignore-not-found >/dev/null &&
|
|
191
|
-
echo "✔ metrics-server removed: $ctx"
|
|
192
|
-
done
|
|
193
|
-
fi
|
|
194
|
-
for ns in ${services[@]+"${services[@]}"}; do
|
|
195
|
-
kubectl --context "$CLUSTER" delete namespace "$ns" --wait=true >/dev/null &&
|
|
196
|
-
echo "✔ namespace removed: $ns ($CLUSTER)"
|
|
197
|
-
done
|
|
198
|
-
for id in ${kind_containers}; do
|
|
199
|
-
docker rm -f "$id" >/dev/null 2>&1 && echo "✔ kind cluster container removed: $id"
|
|
200
|
-
done
|
|
201
|
-
# kind Docker network: removed only if no container uses it anymore
|
|
202
|
-
kind_network=""
|
|
203
|
-
[ "$INSIDE_CONTAINER" = true ] || kind_network="$(docker network inspect kind 2>/dev/null || true)"
|
|
204
|
-
if [ -n "$kind_network" ] && printf '%s\n' "$kind_network" | grep -q '"Containers": {}'; then
|
|
205
|
-
if docker network rm kind >/dev/null 2>&1; then
|
|
206
|
-
echo "✔ kind Docker network removed"
|
|
207
|
-
fi
|
|
208
|
-
fi
|
|
209
|
-
for id in ${labeled_containers}; do
|
|
210
|
-
docker rm -f "$id" >/dev/null 2>&1 && echo "✔ labeled container removed: $id"
|
|
211
|
-
done
|
|
212
|
-
fi
|
|
213
|
-
rm -f "$HERE/.devzone.log" "$STATE"
|
|
214
|
-
|
|
215
|
-
# Instance module state (one "module=on|off" line): removed, modules return to
|
|
216
|
-
# their default values on next start
|
|
217
|
-
rm -f "$HERE/.devzone.modules"
|
|
218
|
-
|
|
219
|
-
# --- What remains ------------------------------------------------------------
|
|
220
|
-
echo
|
|
221
|
-
echo "Not touched (remove yourself if you want):"
|
|
222
|
-
echo " workspace/: your projects"
|
|
223
|
-
for ctx in ${foreign[@]+"${foreign[@]}"}; do
|
|
224
|
-
echo " metrics-server on $ctx: not installed by devzone (kubectl --context $ctx -n kube-system delete deployment metrics-server)"
|
|
225
|
-
done
|
|
226
|
-
command -v kubectl >/dev/null 2>&1 || echo " metrics-server: kubectl not on host, host clusters not checked"
|
|
227
|
-
echo " base image mcr.microsoft.com/devcontainers/base (shared): docker rmi mcr.microsoft.com/devcontainers/base:ubuntu-24.04"
|
|
228
|
-
echo " devcontainer CLI npx cache: ~/.npm/_npx"
|
|
229
|
-
echo " \"GitHub CLI\" authorization on your account: GitHub → Settings → Applications"
|
|
230
|
-
ARGOCD_REPO="$(conf_get argocd repo)"
|
|
231
|
-
if [ -n "$ARGOCD_REPO" ] && [ "$ARGOCD_REPO" != none ]; then
|
|
232
|
-
echo " GitOps repository not removed: $ARGOCD_REPO (delete it yourself if you want to)"
|
|
233
|
-
fi
|
|
234
|
-
echo " this folder: $HERE"
|