devzone 7.4.0 → 7.5.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 (48) hide show
  1. package/.devcontainer/devzone +18 -63
  2. package/.devcontainer/devzone-modules.sh +8 -3
  3. package/.devcontainer/devzone-repair.sh +7 -7
  4. package/.devcontainer/devzone-services.sh +21 -21
  5. package/.devcontainer/devzone-status.sh +12 -9
  6. package/.devcontainer/help.sh +5 -1
  7. package/.devcontainer/versions.env +8 -0
  8. package/.devcontainer/workspace-init.sh +8 -9
  9. package/.gitattributes +8 -0
  10. package/README.md +2 -2
  11. package/bin/SHA256SUMS +6 -6
  12. package/bin/devzone-darwin-amd64 +0 -0
  13. package/bin/devzone-darwin-arm64 +0 -0
  14. package/bin/devzone-linux-amd64 +0 -0
  15. package/bin/devzone-linux-arm64 +0 -0
  16. package/bin/devzone-windows-amd64.exe +0 -0
  17. package/bin/devzone-windows-arm64.exe +0 -0
  18. package/charts/devzone-mysql/values.yaml +1 -1
  19. package/charts/devzone-postgres/values.yaml +1 -1
  20. package/manage/devzone +6 -3
  21. package/manage/scripts/create-mode.sh +3 -3
  22. package/manage/scripts/uninstall.sh +4 -5
  23. package/manage/scripts/workspace/argocd-workspace.sh +2 -2
  24. package/manage/workspace.sh +1 -1
  25. package/package.json +1 -1
  26. package/.devcontainer/ai/host-check.sh +0 -173
  27. package/.devcontainer/ai/host-models.sh +0 -200
  28. package/.devcontainer/catalog/app.sh +0 -202
  29. package/.devcontainer/catalog/catalog-watcher.sh +0 -127
  30. package/.devcontainer/catalog.sh +0 -208
  31. package/.devcontainer/chart-direct.sh +0 -49
  32. package/.devcontainer/cluster.sh +0 -388
  33. package/.devcontainer/clusters.sh +0 -86
  34. package/.devcontainer/devzone-ai-guard.sh +0 -98
  35. package/.devcontainer/devzone-ai.sh +0 -201
  36. package/.devcontainer/devzone-cluster.sh +0 -209
  37. package/.devcontainer/devzone-skill.sh +0 -97
  38. package/.devcontainer/isolation.sh +0 -65
  39. package/.devcontainer/kube-account.sh +0 -107
  40. package/.devcontainer/kube-prompt.sh +0 -42
  41. package/.devcontainer/memory.sh +0 -113
  42. package/.devcontainer/metrics-server.sh +0 -100
  43. package/.devcontainer/packages.sh +0 -228
  44. package/.devcontainer/password.sh +0 -148
  45. package/.devcontainer/ports-json.sh +0 -31
  46. package/.devcontainer/ports.sh +0 -132
  47. package/manage/scripts/create-cluster.sh +0 -107
  48. package/manage/scripts/docker.sh +0 -43
@@ -1,127 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Catalog hot detection (#414): when .devzone.modules changes, catalog.sh apply
3
- # runs. A single instance (lock, as #394).
4
- # catalog-watcher.sh loop | start | stop | tick
5
- set -euo pipefail
6
-
7
- ICI="$(cd "$(dirname "$0")" && pwd)"
8
- RACINE="${DEVZONE_ROOT:-$(cd "$ICI/../.." && pwd)}"
9
- ETAT="${DEVZONE_STATE:-$RACINE/.devzone.modules}"
10
- BASE="${DEVZONE_CATALOG_WATCHER_DIR:-$RACINE/.devzone.catalog-watcher}"
11
- LOCK_DIR="$BASE/lock"
12
- LAST_FILE="$BASE/dernier"
13
-
14
- refuse() { echo "devzone : catalog-watcher : $*" >&2; exit 2; }
15
-
16
- # Guard (#293): never under bats, only with DEVZONE_CATALOG_REAL=yes
17
- guard_watcher() {
18
- if [ "${DEVZONE_CATALOG_REAL:-}" != yes ]; then
19
- echo "devzone : catalog-watcher : refused here (DEVZONE_CATALOG_REAL=yes)" >&2
20
- return 2
21
- fi
22
- if [ -n "${BATS_TEST_TMPDIR:-}" ]; then
23
- echo "devzone : catalog-watcher : refused under bats (tests)" >&2
24
- return 2
25
- fi
26
- return 0
27
- }
28
-
29
- # Exclusive lock (mkdir) with the pid; a single watcher instance
30
- lock_take() {
31
- local start now age pid
32
- start="$(date +%s)"
33
- while true; do
34
- if mkdir "$LOCK_DIR" 2>/dev/null; then echo "$$" >"$LOCK_DIR/pid"; return 0; fi
35
- now="$(date +%s)"
36
- age=""; [ -d "$LOCK_DIR" ] && age="$(stat -c %Y "$LOCK_DIR" 2>/dev/null || stat -f %m "$LOCK_DIR" 2>/dev/null || true)"
37
- pid="$(cat "$LOCK_DIR/pid" 2>/dev/null || true)"
38
- if [ -n "$age" ] && [ "$(( now - age ))" -gt 30 ]; then rm -rf "$LOCK_DIR"; continue; fi
39
- if [ -n "$pid" ] && ! kill -0 "$pid" 2>/dev/null; then rm -rf "$LOCK_DIR"; continue; fi
40
- [ "$(( now - start ))" -ge 5 ] && return 1
41
- sleep 1
42
- done
43
- }
44
-
45
- # Marks the live lock (date and pid up to date)
46
- lock_refresh() { touch "$LOCK_DIR" 2>/dev/null || true; echo "$$" >"$LOCK_DIR/pid" 2>/dev/null || true; }
47
-
48
- # One tick: if .devzone.modules changed since the last tick, apply
49
- tick() {
50
- local now previous
51
- [ -f "$ETAT" ] || return 0
52
- # Restored or rebuilt state: the watcher does not follow a doubtful state,
53
- # and never uninstalls until devzone apply has confirmed it
54
- DEVZONE_STATE="$ETAT" bash "${ICI:-$(dirname "$ICI")}/devzone" state recovery-wait && return 0
55
- DEVZONE_STATE="$ETAT" bash "${ICI:-$(dirname "$ICI")}/devzone" state recovery-pending && return 0
56
- mkdir -p "$BASE"
57
- now="$(stat -c %Y "$ETAT" 2>/dev/null || stat -f %m "$ETAT" 2>/dev/null || true)"
58
- [ -n "$now" ] || return 0
59
- previous="$(cat "$LAST_FILE" 2>/dev/null || true)"
60
- if [ "$now" != "$previous" ]; then
61
- echo "$now" >"$LAST_FILE"
62
- echo "devzone : catalog-watcher : .devzone.modules changed, applying" >&2
63
- bash "$ICI/../catalog.sh" apply
64
- fi
65
- }
66
-
67
- # Loop: one tick every 5 s, lock refreshed on each tick
68
- loop() {
69
- mkdir -p "$BASE"
70
- if ! lock_take; then return 0; fi
71
- trap 'rm -rf "$LOCK_DIR"' EXIT INT TERM
72
- while true; do
73
- [ -f "$ETAT" ] || { rm -rf "$LOCK_DIR"; break; }
74
- lock_refresh
75
- tick || true
76
- sleep 5
77
- done
78
- }
79
-
80
- # Starts the detached loop (#435) and checks that its lock is alive
81
- start_detached() {
82
- local i pid stable=0 detache=()
83
- mkdir -p "$BASE"
84
- # Same detachment as relay_start: setsid when present, else nohup.
85
- command -v setsid >/dev/null 2>&1 && detache=(setsid)
86
- ${detache[@]+"${detache[@]}"} nohup env DEVZONE_CATALOG_REAL=yes bash "$0" loop >"$BASE/veilleur.log" 2>&1 &
87
- i=0
88
- while [ "$i" -lt 20 ]; do
89
- pid="$(cat "$LOCK_DIR/pid" 2>/dev/null || true)"
90
- if [ -n "$pid" ] && kill -0 "$pid" 2>/dev/null; then
91
- stable=$((stable + 1))
92
- [ "$stable" -ge 5 ] && { echo "started"; return 0; }
93
- else
94
- stable=0
95
- fi
96
- sleep 0.1
97
- i=$((i + 1))
98
- done
99
- echo "devzone : catalog-watcher : cannot start, see $BASE/veilleur.log" >&2
100
- return 1
101
- }
102
-
103
- # Stops the watcher and removes the lock
104
- stop_watcher() {
105
- local pid
106
- pid="$(cat "$LOCK_DIR/pid" 2>/dev/null || true)"
107
- if [ -n "$pid" ]; then kill "$pid" 2>/dev/null || true; fi
108
- rm -rf "$LOCK_DIR"
109
- }
110
-
111
- case "${1:-}" in
112
- loop) if ! guard_watcher; then exit 2; fi; loop ;;
113
- start)
114
- if ! guard_watcher; then exit 2; fi
115
- if [ -f "$LOCK_DIR/pid" ] && kill -0 "$(cat "$LOCK_DIR/pid")" 2>/dev/null; then
116
- echo "already running"
117
- else
118
- start_detached || exit 1
119
- fi
120
- ;;
121
- stop) stop_watcher ; echo "stopped" ;;
122
- tick) tick ;;
123
- *)
124
- echo "devzone : catalog-watcher : loop | start | stop | tick" >&2
125
- exit 2
126
- ;;
127
- esac
@@ -1,208 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Application catalog (#414): one preconfigured application per folder
3
- # .devcontainer/catalog/<app>/ (app.conf; the chart charts/devzone-<app>, #559),
4
- # installed in the devzone services cluster under the namespace of its app.conf;
5
- # the wanted state is the line <app>=on|off of .devzone.modules.
6
- # catalog.sh sync | apply | list | resume | json | remove <app>
7
- set -euo pipefail
8
-
9
- ICI="$(cd "$(dirname "$0")" && pwd)"
10
- RACINE="${DEVZONE_ROOT:-$(dirname "$ICI")}"
11
- ETAT="${DEVZONE_STATE:-$RACINE/.devzone.modules}"
12
- # shellcheck source=SCRIPTDIR/cluster.sh
13
- # shellcheck disable=SC1091
14
- . "$ICI/cluster.sh"
15
- # shellcheck source=SCRIPTDIR/password.sh
16
- # shellcheck disable=SC1091
17
- . "$ICI/password.sh"
18
- # shellcheck source=SCRIPTDIR/isolation.sh
19
- # shellcheck disable=SC1091
20
- . "$ICI/isolation.sh"
21
- # shellcheck source=SCRIPTDIR/catalog/app.sh
22
- # shellcheck disable=SC1091
23
- . "$ICI/catalog/app.sh"
24
-
25
- refuse() { echo "devzone : catalog : $*" >&2; exit 2; }
26
-
27
- # Catalog folder (overridable by the tests)
28
- catalog_dir() { echo "${DEVZONE_CATALOG:-$ICI/catalog}"; }
29
-
30
- # Catalog applications: folders holding an app.conf, sorted
31
- catalog_apps() {
32
- local d
33
- for d in "$(catalog_dir)"/*; do
34
- [ -f "$d/app.conf" ] || continue
35
- echo "${d##*/}"
36
- done | LC_ALL=C sort
37
- }
38
-
39
- # app.conf key (name, description, image, port, memoire, taille, namespace)
40
- app_read() {
41
- grep -E "^$2=" "$(catalog_dir)/$1/app.conf" 2>/dev/null | tail -1 | cut -d= -f2- || true
42
- }
43
-
44
- # Application namespace: the one of app.conf (required)
45
- app_namespace() {
46
- local ns
47
- ns="$(app_read "$1" namespace)"
48
- [ -n "$ns" ] || refuse "missing namespace in app.conf of $1"
49
- echo "$ns"
50
- }
51
-
52
- # Failure marker of an application: same scheme as the failure file of the modules
53
- failure_file() { echo "$ETAT-failed-$1"; }
54
-
55
- # Wanted state: on if the line <app>=on exists, off by default
56
- wanted() {
57
- local v
58
- v="$(grep -E "^$1=" "$ETAT" 2>/dev/null | tail -1 | cut -d= -f2- || true)"
59
- [ "$v" = on ] && echo on || echo off
60
- }
61
-
62
- # Application present in the cluster. In the Kubernetes workspace pod: its
63
- # service resolves in the cluster DNS (no RBAC needed, #515). Elsewhere: labelled
64
- # namespace and StatefulSet of the app name; reading the namespaces is reserved
65
- # to the administrator (#430). Nothing without a chosen cluster or when absent.
66
- present() {
67
- local ctx ns
68
- ns="$(app_namespace "$1")"
69
- if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
70
- # In the pod there is no kubeconfig and the limited service account
71
- # cannot list StatefulSets (#430): presence is the cluster DNS
72
- # resolving the service, no RBAC needed, the pod service account
73
- # stays limited
74
- getent hosts "$(app_read "$1" name).${ns}.svc" >/dev/null 2>&1
75
- return
76
- fi
77
- ctx="$(cluster_saved)"
78
- [ -n "$ctx" ] || return 1
79
- account_admin "$ctx" get namespace "$ns" >/dev/null 2>&1 &&
80
- kubectl --context devzone -n "$ns" get statefulset "$1" >/dev/null 2>&1
81
- }
82
-
83
- # Application ready: the StatefulSet has one ready replica
84
- app_ready() {
85
- local ns
86
- ns="$(app_namespace "$1")"
87
- [ "$(kubectl --context devzone -n "$ns" get statefulset "$1" \
88
- -o jsonpath='{.status.readyReplicas}' 2>/dev/null || true)" = 1 ]
89
- }
90
-
91
- # Adds to the state the <app>=off lines of the absent applications (once each,
92
- # an existing line is never changed), under the Go state lock (#879).
93
- catalog_sync() {
94
- DEVZONE_STATE="$ETAT" bash "$ICI/devzone" state catalog-sync
95
- }
96
-
97
- # Real state of an application: available, expected, installed, failed. These
98
- # values are the etat field of devzone status --json: keep them
99
- app_state() {
100
- local app="$1"
101
- if [ "$(wanted "$app")" != on ]; then
102
- echo available
103
- elif [ -f "$(failure_file "$app")" ]; then
104
- echo failed
105
- elif present "$app"; then
106
- echo installed
107
- else
108
- echo expected
109
- fi
110
- }
111
-
112
- # devzone catalog: name, state (off, on installed, on failed), description
113
- catalog_list() {
114
- local app state label
115
- while IFS= read -r app; do
116
- [ -n "$app" ] || continue
117
- state="$(app_state "$app")"
118
- case "$state" in
119
- available) label='off available' ;;
120
- installed) label='on installed' ;;
121
- failed) label='on failed' ;;
122
- *) label='on expected' ;;
123
- esac
124
- printf ' %-12s %-14s %s\n' "$app" "$label" "$(app_read "$app" description)"
125
- done <<<"$(catalog_apps)"
126
- }
127
-
128
- # Relay of the installed application: state of its script, else the relay pid
129
- app_relay_stopped() {
130
- local app="$1" script state
131
- if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
132
- # In the pod, no relay: the access goes through the workspace ports
133
- return 1
134
- fi
135
- script="$ICI/catalog/$app/$app.sh"
136
- if [ -f "$script" ]; then
137
- state="$(bash "$script" status 2>/dev/null || true)"
138
- case "$state" in *"relay stopped"*) return 0 ;; esac
139
- fi
140
- ! relay_active "$app"
141
- }
142
-
143
- # Application lines of devzone's summary: ○ available, ✔ installed (relay
144
- # address), ✖ failed, ⚠ expected
145
- catalog_summary() {
146
- local app
147
- while IFS= read -r app; do
148
- [ -n "$app" ] || continue
149
- case "$(app_state "$app")" in
150
- available) printf ' ○ application %-12s available, %s: devzone enable %s\n' \
151
- "$app" "$(app_read "$app" description)" "$app" ;;
152
- installed)
153
- if app_relay_stopped "$app"; then
154
- printf ' ⚠ application %-12s installed, relay stopped: devzone repair\n' "$app"
155
- else
156
- if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
157
- printf ' ✔ application %-12s installed: local access: devzone workspace ports\n' "$app"
158
- else
159
- printf ' ✔ application %-12s installed: 127.0.0.1:%s\n' \
160
- "$app" "$(app_read "$app" port)"
161
- fi
162
- fi ;;
163
- expected) printf ' ⚠ application %-12s expected: devzone apply\n' "$app" ;;
164
- *) printf ' ✖ application %s failed: %s: devzone apply\n' \
165
- "$app" "$(head -1 "$(failure_file "$app")")" ;;
166
- esac
167
- done <<<"$(catalog_apps)"
168
- app_unused_mysql_volumes 2>/dev/null || true
169
- }
170
-
171
- # Applications section of devzone status --json: same fields as the modules
172
- catalog_json() {
173
- local app active state failure cmd json='[]'
174
- while IFS= read -r app; do
175
- [ -n "$app" ] || continue
176
- active=false
177
- [ "$(wanted "$app")" = on ] && active=true
178
- state="$(app_state "$app")"
179
- failure=""
180
- cmd="devzone apply"
181
- case "$state" in
182
- available) cmd="devzone enable $app" ;;
183
- installed) cmd="devzone disable $app" ;;
184
- failed) failure="$(head -1 "$(failure_file "$app")")" ;;
185
- esac
186
- json="$(jq -cn --argjson before "$json" --arg name "$app" --argjson active "$active" \
187
- --arg description "$(app_read "$app" description)" \
188
- --arg state "$state" --arg port "$(app_read "$app" port)" \
189
- --arg failure "$failure" --arg command "$cmd" \
190
- '$before + [{name:$name,active:$active,description:$description,port:$port,state:$state,failed:(if $failure=="" then null else $failure end),command:(if $command=="" then null else $command end)}]')"
191
- done <<<"$(catalog_apps)"
192
- printf '%s\n' "$json"
193
- }
194
-
195
- case "${1:-}" in
196
- sync) catalog_sync ;;
197
- apply) catalog_apply ;;
198
- list) catalog_list ;;
199
- resume) catalog_summary ;;
200
- json) catalog_json ;;
201
- # Removal of an application: StatefulSet and service, volume kept (#441)
202
- remove) app_remove "$2" ;;
203
- -h | --help) sed -n '2,6p' "$0" | sed 's/^# \{0,1\}//' ;;
204
- *)
205
- echo "devzone : catalog : sync | apply | list | resume | json | remove <app>" >&2
206
- exit 1
207
- ;;
208
- esac
@@ -1,49 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Helm-direct installation of a devzone service (#559, step 7): the chart
3
- # charts/devzone-<svc> of the code tree is the only definition, installed with
4
- # helm on the devzone context as the release <svc> in <ns>. Objects already
5
- # there (kubectl apply of an earlier version, or left by Argo CD when its module
6
- # went away) are adopted first: the annotations and the label helm requires, so
7
- # that the release takes them over without recreating them.
8
- # chart_install <svc> <ns> [key=value ...] adoption, then helm upgrade --install
9
- # bash 3.2 (macOS).
10
-
11
- # The charts are code: read from the code tree (this file is in .devcontainer/),
12
- # whatever the devzone folder (RACINE, the state) is
13
- CHART_CODE="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
14
-
15
- # Adopts the objects of the rendered chart that already exist in <ns>: helm
16
- # refuses an object it does not own, so the release annotations and the
17
- # managed-by label are written on them (no object is recreated)
18
- chart_adopt() {
19
- local svc="$1" ns="$2" rendu="$3" objets o
20
- objets="$(kubectl --context devzone -n "$ns" get -f "$rendu" -o name --ignore-not-found 2>/dev/null || true)"
21
- for o in $objets; do
22
- kubectl --context devzone -n "$ns" annotate "$o" \
23
- "meta.helm.sh/release-name=$svc" "meta.helm.sh/release-namespace=$ns" --overwrite >/dev/null
24
- kubectl --context devzone -n "$ns" label "$o" app.kubernetes.io/managed-by=Helm --overwrite >/dev/null
25
- done
26
- }
27
-
28
- # Installs or upgrades the release <svc> from charts/devzone-<svc>; the
29
- # key=value arguments become --set options (image, port, memory, size, claim)
30
- chart_install() {
31
- local svc="$1" ns="$2" chart rendu arg
32
- local -a sets
33
- shift 2
34
- chart="$CHART_CODE/charts/devzone-$svc"
35
- if [ ! -f "$chart/Chart.yaml" ]; then
36
- echo "✖ $svc : chart charts/devzone-$svc missing (manage/docs/reference.md#devzone-charts)" >&2
37
- return 2
38
- fi
39
- sets=()
40
- for arg in "$@"; do sets+=(--set "$arg"); done
41
- rendu="$(mktemp)"
42
- if ! helm template "$svc" "$chart" -n "$ns" ${sets[@]+"${sets[@]}"} >"$rendu"; then
43
- rm -f "$rendu"
44
- return 1
45
- fi
46
- chart_adopt "$svc" "$ns" "$rendu"
47
- rm -f "$rendu"
48
- helm --kube-context devzone upgrade --install "$svc" "$chart" -n "$ns" ${sets[@]+"${sets[@]}"} >/dev/null
49
- }