devzone 7.1.1 → 7.3.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 (50) hide show
  1. package/.devcontainer/Dockerfile +14 -14
  2. package/.devcontainer/ai/host-check.message +12 -12
  3. package/.devcontainer/ai/host-check.sh +1 -1
  4. package/.devcontainer/catalog/catalog-watcher.sh +9 -12
  5. package/.devcontainer/catalog.sh +5 -28
  6. package/.devcontainer/cluster.sh +1 -4
  7. package/.devcontainer/devzone +27 -25
  8. package/.devcontainer/devzone-ai.sh +1 -1
  9. package/.devcontainer/devzone-cluster.sh +1 -2
  10. package/.devcontainer/devzone-modules.sh +9 -20
  11. package/.devcontainer/devzone-repair.sh +3 -3
  12. package/.devcontainer/devzone-services.sh +2 -2
  13. package/.devcontainer/devzone-status.sh +1 -1
  14. package/.devcontainer/gitlab/demo/.gitlab-ci.yml +1 -1
  15. package/.devcontainer/help.sh +0 -1
  16. package/.devcontainer/packages.sh +1 -1
  17. package/.devcontainer/password.sh +5 -6
  18. package/.devcontainer/ports.sh +3 -6
  19. package/.devcontainer/services-admin.sh +5 -8
  20. package/.devcontainer/workspace-init.sh +0 -7
  21. package/Makefile +3 -3
  22. package/README.md +1 -13
  23. package/bin/SHA256SUMS +6 -6
  24. package/bin/devzone-darwin-amd64 +0 -0
  25. package/bin/devzone-darwin-arm64 +0 -0
  26. package/bin/devzone-linux-amd64 +0 -0
  27. package/bin/devzone-linux-arm64 +0 -0
  28. package/bin/devzone-windows-amd64.exe +0 -0
  29. package/bin/devzone-windows-arm64.exe +0 -0
  30. package/manage/devzone +6 -17
  31. package/manage/scripts/ci/check-names.sh +5 -6
  32. package/manage/scripts/ci/ticket-protocol.txt +7 -0
  33. package/manage/scripts/ci/versions-tools-plan.sh +1 -1
  34. package/manage/scripts/devzone-create.sh +4 -4
  35. package/manage/scripts/devzone-update.sh +18 -22
  36. package/manage/scripts/workspace/argocd-services.sh +1 -1
  37. package/manage/scripts/workspace/argocd-workspace.sh +2 -2
  38. package/manage/scripts/workspace/ports-workspace.sh +5 -5
  39. package/manage/scripts/workspace/services-workspace.sh +3 -3
  40. package/manage/scripts/workspace/workspace-update.sh +0 -3
  41. package/manage/workspace.sh +0 -14
  42. package/package.json +1 -1
  43. package/.devcontainer/command-aliases.sh +0 -234
  44. package/.devcontainer/rename-legacy-files.sh +0 -172
  45. package/.devcontainer/rename-legacy-ports.sh +0 -119
  46. package/.devcontainer/state-gitops.sh +0 -23
  47. package/.devcontainer/state-json.sh +0 -282
  48. package/.devcontainer/state-lock.sh +0 -53
  49. package/.devcontainer/state.sh +0 -219
  50. package/manage/scripts/ci/check-english.sh +0 -57
@@ -1,282 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Machine output of devzone status (--json): stable, versioned JSON object.
3
- # Sourced by devzone: reuses its functions (value_of, description, …), does not
4
- # rewrite etat(). Built only with jq. JSON keys are a contract: English names
5
- # (#733), listed in manage/docs/reference.md.
6
-
7
- # Adds an entry to $errors: the section that failed and why.
8
- add_error() {
9
- errors="$(jq -c --arg k "$1" --arg v "$2" '. + {($k): $v}' <<<"$errors")"
10
- }
11
-
12
- # Adds an alert (code, message, devzone command to run) to $alerts_json.
13
- append_alert() {
14
- local code="$1" message="$2" command="${3:-}"
15
- alerts_json="$(jq -c \
16
- --arg code "$code" \
17
- --arg message "$message" \
18
- --arg command "$command" \
19
- '. + [{code:$code,message:$message,command:(if $command=="" then null else $command end)}]' \
20
- <<<"$alerts_json")"
21
- }
22
-
23
- # Full state of the machine in JSON: repeats each section of etat() with the
24
- # same commands, isolating each computation (failure → null value and errors).
25
- state_json() {
26
- local errors='{}'
27
- local alerts_json='[]'
28
- local dv_raw="" dvp_raw=""
29
- local id_name="" id_email="" id_ok=false id_command=""
30
- local platform_name platform_url="" github_json="null"
31
- local tools_late_json='[]' tools_command=""
32
- local modules_json='[]' m active desc failure_file content state_value failure_value command_value out argocd_repo=""
33
- local services_cluster="" services_remote=false
34
- local work_ctx="" work_internal=false host_ctx=""
35
- local clusters_services_raw="" clusters_work_raw="" clusters_command=""
36
- local ports_json='[]' ports_out
37
- local applications_json='[]'
38
- local credentials_raw=""
39
- local late_out package frozen installed count
40
- local packages_marker packages_names n path wt_out
41
- local gh_status gh_code
42
-
43
- if v="$(folder_version 2>/dev/null)"; then
44
- dv_raw="$v"
45
- else
46
- add_error devzone "folder_version unavailable"
47
- fi
48
- dvp_raw="$(published_version 2>/dev/null || true)"
49
-
50
- id_name="$(git config --get user.name 2>/dev/null || true)"
51
- id_email="$(git config --get user.email 2>/dev/null || true)"
52
- if [ -n "$id_name" ] && [ -n "$id_email" ]; then
53
- id_ok=true
54
- else
55
- id_command='gh auth login -s workflow (automatic), or git config --file ~/.config/git/config user.name "<name>" and user.email "<email>"'
56
- fi
57
-
58
- platform_name="$(platform_read)"
59
- if [ "$platform_name" = gitlab ]; then
60
- platform_url="$(gitlab_url_read)"
61
- else
62
- platform_url=""
63
- fi
64
- if [ "$platform_name" = github ]; then
65
- gh_status="$(gh auth status 2>&1)" && gh_code=0 || gh_code=$?
66
- if [ "$gh_code" -ne 0 ]; then
67
- github_json="null"
68
- add_error github "gh auth status failed"
69
- else
70
- if printf '%s\n' "$gh_status" | grep -q "Token scopes:" && ! printf '%s\n' "$gh_status" | grep -q "'workflow'"; then
71
- github_json="$(jq -cn '{connected:true,workflow:false,command:"gh auth refresh -h github.com -s workflow"}')"
72
- else
73
- github_json="$(jq -cn '{connected:true,workflow:true,command:null}')"
74
- fi
75
- fi
76
- else
77
- github_json="null"
78
- fi
79
-
80
- if late_out="$(outdated_tools 2>/dev/null)"; then
81
- tools_late_json='[]'
82
- while IFS= read -r line; do
83
- [ -n "$line" ] || continue
84
- # shellcheck disable=SC2086
85
- set -- $line
86
- package="${1:-}"; frozen="${2:-}"; installed="${3:-}"
87
- [ -n "$package" ] || continue
88
- tools_late_json="$(jq -c \
89
- --arg p "$package" --arg f "$frozen" --arg i "$installed" \
90
- '. + [{package:$p,frozen:$f,installed:$i}]' <<<"$tools_late_json")"
91
- done <<<"$late_out"
92
- count="$(jq 'length' <<<"$tools_late_json" 2>/dev/null || echo 0)"
93
- if [ "$count" -gt 0 ]; then
94
- tools_command="devzone apply"
95
- fi
96
- else
97
- tools_late_json="null"
98
- add_error tools "outdated_tools unavailable"
99
- fi
100
-
101
- modules_json='[]'
102
- for m in "${MODULES[@]}"; do
103
- active=false
104
- [ "$(value_of "$m")" = on ] && active=true
105
- desc="$(description "$m")"
106
- failure_value=""
107
- state_value=""
108
- command_value=""
109
- if in_pod && service_module "$m"; then
110
- # Kubernetes workspace pod (#528): presence by the cluster DNS,
111
- # installation from the workstation; no failure marker read here
112
- if service_present "$m"; then
113
- state_value="active: $(service_dns "$m")"
114
- elif [ "$active" = true ]; then
115
- state_value="not in the cluster"
116
- command_value="devzone workspace services enable $m"
117
- else
118
- state_value="optional"
119
- command_value="devzone workspace services enable $m"
120
- fi
121
- elif [ "$active" = true ]; then
122
- failure_file="$(failure_marker_file "$m")"
123
- if [ -f "$failure_file" ]; then
124
- content="$(cat "$failure_file" 2>/dev/null || true)"
125
- failure_value="$content"
126
- state_value="failed"
127
- command_value="devzone apply"
128
- elif [ "$m" = gitlab ]; then
129
- if out="$(devzone gitlab status 2>/dev/null)"; then
130
- state_value="$out"
131
- else
132
- state_value=""
133
- add_error modules "gitlab status unavailable"
134
- fi
135
- elif [ "$m" = postgres ] || [ "$m" = llm ]; then
136
- if out="$(bash "$ICI/$m/$m.sh" status 2>/dev/null)"; then
137
- state_value="$out"
138
- else
139
- state_value=""
140
- add_error modules "$m.sh state unavailable"
141
- fi
142
- elif [ "$m" = argocd ]; then
143
- if out="$("$ICI/devzone" argocd status 2>/dev/null)"; then
144
- state_value="$out"
145
- else
146
- state_value=""
147
- fi
148
- elif [ "$m" = mysql ]; then
149
- if out="$(devzone mysql status 2>/dev/null)"; then
150
- state_value="$out"
151
- else
152
- state_value=""
153
- add_error modules "mysql.sh status unavailable"
154
- fi
155
- else
156
- state_value="active"
157
- fi
158
- else
159
- state_value="optional"
160
- command_value="devzone enable $m"
161
- fi
162
- modules_json="$(jq -c \
163
- --arg name "$m" \
164
- --argjson active "$active" \
165
- --arg description "$desc" \
166
- --arg state "$state_value" \
167
- --arg failure "$failure_value" \
168
- --arg command "$command_value" \
169
- '. + [{name:$name,active:$active,description:$description,state:(if $state=="" then null else $state end),failed:(if $failure=="" then null else $failure end),command:(if $command=="" then null else $command end)}]' \
170
- <<<"$modules_json")"
171
- done
172
-
173
- services_cluster="$(cluster_saved)"
174
- if [ -n "$services_cluster" ] && ! cluster_is_local "$services_cluster"; then
175
- services_remote=true
176
- fi
177
- clusters_services_raw="$services_cluster"
178
- work_ctx="$(kubectl config current-context 2>/dev/null || true)"
179
- case "$work_ctx" in
180
- kind-gitlab* | kind-devzone*)
181
- host_ctx="$(KUBECONFIG="${DEVZONE_KUBE_HOST:-$HOME/.kube/hote.config}" kubectl config current-context 2>/dev/null || true)"
182
- if [ -n "$host_ctx" ] && cluster_reachable "$host_ctx" 2>/dev/null; then
183
- work_internal=true
184
- fi
185
- ;;
186
- esac
187
- clusters_work_raw="$work_ctx"
188
- if [ "$work_internal" = true ]; then
189
- clusters_command="devzone use $host_ctx"
190
- fi
191
-
192
- devzone cluster clean --quiet >/dev/null 2>&1 || [ $? -ne 3 ] || append_alert cluster_disk "cluster disk almost full" "devzone repair"
193
- if ports_out="$(bash "$ICI/ports.sh" list --json 2>/dev/null)"; then
194
- if printf '%s' "$ports_out" | jq -e . >/dev/null 2>&1; then
195
- ports_json="$ports_out"
196
- else
197
- ports_json="null"
198
- add_error ports "ports output unreadable"
199
- fi
200
- else
201
- ports_json="null"
202
- add_error ports "ports.sh unavailable"
203
- fi
204
-
205
- applications_json="$(bash "$ICI/catalog.sh" json 2>/dev/null || echo '[]')"
206
- if ! printf '%s' "$applications_json" | jq -e . >/dev/null 2>&1; then
207
- applications_json='[]'
208
- add_error modules "catalog.sh json unavailable"
209
- fi
210
-
211
- if [ -f "$RACINE/.password" ]; then
212
- credentials_raw="$RACINE/.password"
213
- fi
214
-
215
- packages_marker="${DEVZONE_PACKAGES_MARKER:-/tmp/devzone-packages.failed}"
216
- if [ -f "$packages_marker" ]; then
217
- packages_names=""
218
- while IFS= read -r n; do
219
- [ -n "$n" ] || continue
220
- packages_names="${packages_names:+$packages_names, }$n"
221
- done < "$packages_marker"
222
- append_alert packages "$packages_names" "devzone packages"
223
- fi
224
- wt_out="$(missing_worktrees 2>/dev/null || true)"
225
- while IFS= read -r path; do
226
- [ -n "$path" ] || continue
227
- append_alert worktree "$path missing here (created outside the container?)" ""
228
- done <<<"$wt_out"
229
- if [ -n "$services_cluster" ] && ! cluster_is_local "$services_cluster"; then
230
- append_alert cluster_distant "remote cluster: $services_cluster — services on a remote cluster" ""
231
- fi
232
- if [ "$work_internal" = true ]; then
233
- append_alert cluster_interne "work cluster: $work_ctx (devzone internal cluster)" "devzone use $host_ctx"
234
- fi
235
-
236
- argocd_repo="$(conf_get argocd repo)"
237
-
238
- jq -n \
239
- --argjson schema 3 \
240
- --arg dv "$dv_raw" \
241
- --arg dvp "$dvp_raw" \
242
- --argjson id_ok "$id_ok" \
243
- --arg id_name "$id_name" \
244
- --arg id_email "$id_email" \
245
- --arg id_command "$id_command" \
246
- --arg platform_name "$platform_name" \
247
- --arg platform_url "$platform_url" \
248
- --argjson github "$github_json" \
249
- --argjson tools_late "$tools_late_json" \
250
- --arg tools_command "$tools_command" \
251
- --argjson modules "$modules_json" \
252
- --arg argocd_repo "$argocd_repo" \
253
- --arg clusters_services "$clusters_services_raw" \
254
- --argjson services_remote "$services_remote" \
255
- --arg clusters_work "$clusters_work_raw" \
256
- --argjson work_internal "$work_internal" \
257
- --arg clusters_command "$clusters_command" \
258
- --argjson ports "$ports_json" \
259
- --argjson applications "$applications_json" \
260
- --arg credentials "$credentials_raw" \
261
- --argjson alerts "$alerts_json" \
262
- --argjson errors "$errors" \
263
- '{
264
- schema: $schema,
265
- devzone: { version: (if $dv=="" then null else $dv end), available: (if $dvp=="" then null else $dvp end) },
266
- git_identity: { ok: $id_ok, name: (if $id_name=="" then null else $id_name end), email: (if $id_email=="" then null else $id_email end), command: (if $id_command=="" then null else $id_command end) },
267
- platform: { name: $platform_name, url: (if $platform_url=="" then null else $platform_url end), github: $github },
268
- argocd_repo: (if $argocd_repo == "" then null else $argocd_repo end),
269
- tools: { outdated: $tools_late, command: (if $tools_command=="" then null else $tools_command end) },
270
- modules: $modules,
271
- clusters: { services: (if $clusters_services=="" then null else $clusters_services end), services_remote: $services_remote, work: (if $clusters_work=="" then null else $clusters_work end), internal_work: $work_internal, command: (if $clusters_command=="" then null else $clusters_command end) },
272
- ports: $ports,
273
- applications: (if $applications=="" then null else $applications end),
274
- credentials: (if $credentials=="" then null else $credentials end),
275
- alerts: $alerts,
276
- errors: $errors
277
- }'
278
- }
279
-
280
- if [ "${BASH_SOURCE[0]}" = "$0" ]; then
281
- state_json
282
- fi
@@ -1,53 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Write lock of the module state, sourced by state.sh (#417 and #476)
3
- # state_lock_take / state_lock_release write lock
4
-
5
- # Exclusive lock (mkdir): one write at a time. A vanished holder is guessed
6
- # from the age of the folder (no kill) and the depth counter makes the lock
7
- # re-takeable within the same process (init then write).
8
- state_lock_take() {
9
- local age start
10
- [ "${STATE_LOCK_DEPTH:-0}" -gt 0 ] && { STATE_LOCK_DEPTH=$((STATE_LOCK_DEPTH + 1)); return 0; }
11
- mkdir -p "$(dirname "$ETAT")" || return 1
12
- start="$(date +%s)"
13
- while ! mkdir "${ETAT}.lockdir" 2>/dev/null; do
14
- age="$(stat -c %Y "${ETAT}.lockdir" 2>/dev/null || stat -f %m "${ETAT}.lockdir" 2>/dev/null || true)"
15
- if [ -n "$age" ] && [ "$(( $(date +%s) - age ))" -gt 30 ]; then
16
- rm -rf "${ETAT}.lockdir"
17
- continue
18
- fi
19
- if [ "$(( $(date +%s) - start ))" -ge 10 ]; then
20
- echo "devzone : state locked elsewhere: ${ETAT}.lockdir" >&2
21
- return 1
22
- fi
23
- sleep 1
24
- done
25
- # flock serializes the write when it exists (Linux); mkdir stays the only
26
- # guard on macOS (#476, same pattern as #461).
27
- if command -v flock >/dev/null 2>&1; then
28
- if { exec 8>"${ETAT}.lock"; } && flock -w 10 8; then
29
- STATE_LOCK_FLOCK=1
30
- else
31
- rm -rf "${ETAT}.lockdir" 2>/dev/null || true
32
- echo "devzone : state locked elsewhere (flock): ${ETAT}.lock" >&2
33
- return 1
34
- fi
35
- fi
36
- STATE_LOCK_DEPTH=1
37
- return 0
38
- }
39
-
40
- # Releases the lock taken by this process; depth > 1: still held
41
- state_lock_release() {
42
- local depth="${STATE_LOCK_DEPTH:-0}"
43
- [ "$depth" -gt 0 ] || return 0
44
- [ "$depth" -gt 1 ] && { STATE_LOCK_DEPTH=$((depth - 1)); return 0; }
45
- STATE_LOCK_DEPTH=0
46
- if [ "${STATE_LOCK_FLOCK:-0}" = 1 ]; then
47
- flock -u 8 2>/dev/null || true
48
- exec 8>&-
49
- STATE_LOCK_FLOCK=0
50
- fi
51
- rm -rf "${ETAT}.lockdir" 2>/dev/null || true
52
- return 0
53
- }
@@ -1,219 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Safe write of the module state (#417): the only place that sets, replaces
3
- # or removes a line of $ETAT. A mkdir lock prevents two simultaneous writes,
4
- # the temporary file is created in the state folder (the mv stays atomic: the
5
- # file is never missing or incomplete for a reader) and a backup copy
6
- # $ETAT.prev precedes each replacement. The same file creates the state when
7
- # it is missing: former global state taken over once, backup copy restored,
8
- # state rebuilt from the services cluster, otherwise first installation.
9
- # Sourced library: the caller defines ETAT (file name kept: shared by callers).
10
- # state_write <key> <value> sets or replaces the line <key>=<value>
11
- # state_remove <key> removes the line <key>=
12
- # state_replace <file> replaces the whole state with this file
13
- # state_lock_take / state_lock_release write lock
14
- # state_recovery_* state restored or rebuilt (step 4)
15
- # state_init [modules…] creates the state if it is missing
16
-
17
- # Write lock (#476): state_lock_take, state_lock_release
18
- # shellcheck source=SCRIPTDIR/state-lock.sh
19
- # shellcheck disable=SC1091
20
- . "$(dirname "${BASH_SOURCE[0]}")/state-lock.sh"
21
-
22
- # Abort under lock: the temporary file goes, the lock is released
23
- state_abort() {
24
- rm -f "${1:-}"
25
- state_lock_release
26
- return 1
27
- }
28
-
29
- # Backup copy of the current state, before replacement
30
- state_backup() {
31
- [ -f "$ETAT" ] || return 0
32
- cp "$ETAT" "${ETAT}.prev"
33
- }
34
-
35
- # The state without the line $1, written to the temporary file $2
36
- state_filter() {
37
- local key="$1" dst="$2" code=0
38
- [ -f "$ETAT" ] || return 0
39
- grep -vE "^${key}=" "$ETAT" >"$dst" || code=$?
40
- [ "$code" -le 1 ] || return 1
41
- return 0
42
- }
43
-
44
- # Under lock: replaces the whole state with a file, $ETAT.prev backed up
45
- state_replace() {
46
- local src="$1" tmp
47
- [ -f "$src" ] || return 1
48
- state_lock_take || return 1
49
- state_backup || { state_lock_release; return 1; }
50
- tmp="$(mktemp "${ETAT}.XXXXXX")" || { state_lock_release; return 1; }
51
- cat "$src" >"$tmp" || { state_abort "$tmp"; return 1; }
52
- mv "$tmp" "$ETAT" || { state_abort "$tmp"; return 1; }
53
- state_lock_release
54
- return 0
55
- }
56
-
57
- # Under lock: new value of a key, without losing the other lines
58
- state_write() {
59
- local key="$1" value="$2" tmp
60
- state_lock_take || return 1
61
- state_backup || { state_lock_release; return 1; }
62
- tmp="$(mktemp "${ETAT}.XXXXXX")" || { state_lock_release; return 1; }
63
- state_filter "$key" "$tmp" || { state_abort "$tmp"; return 1; }
64
- printf '%s=%s\n' "$key" "$value" >>"$tmp" || { state_abort "$tmp"; return 1; }
65
- mv "$tmp" "$ETAT" || { state_abort "$tmp"; return 1; }
66
- state_lock_release
67
- return 0
68
- }
69
-
70
- # Under lock: removes a key (#417); without state, nothing to remove
71
- state_remove() {
72
- local key="$1" tmp
73
- state_lock_take || return 1
74
- [ -f "$ETAT" ] || { state_lock_release; return 0; }
75
- state_backup || { state_lock_release; return 1; }
76
- tmp="$(mktemp "${ETAT}.XXXXXX")" || { state_lock_release; return 1; }
77
- state_filter "$key" "$tmp" || { state_abort "$tmp"; return 1; }
78
- mv "$tmp" "$ETAT" || { state_abort "$tmp"; return 1; }
79
- state_lock_release
80
- return 0
81
- }
82
-
83
- # Marks a restored or rebuilt state: the watchers wait (#417)
84
- state_recovery_mark() {
85
- date +%s >"${ETAT}.recouvre" 2>/dev/null || true
86
- }
87
-
88
- # 0 (to wait) less than 60 s after a restore or a rebuild
89
- state_recovery_wait() {
90
- local mark
91
- [ -f "${ETAT}.recouvre" ] || return 1
92
- mark="$(cat "${ETAT}.recouvre" 2>/dev/null || true)"
93
- case "$mark" in
94
- '' | *[!0-9]*) return 1 ;;
95
- esac
96
- [ "$(( $(date +%s) - mark ))" -lt 60 ]
97
- }
98
-
99
- # 0 if the restored or rebuilt state is not yet confirmed (#417)
100
- state_recovery_pending() {
101
- [ -f "${ETAT}.recouvre" ]
102
- }
103
-
104
- # The user confirmed the state (devzone apply): no more guard
105
- state_recovery_confirm() {
106
- rm -f "${ETAT}.recouvre" 2>/dev/null || true
107
- return 0
108
- }
109
-
110
- # First installation (#417): the default state, written in one go
111
- state_default() {
112
- local stage code=0
113
- stage="$(mktemp)" || return 1
114
- printf 'ai=off\nkubernetes=off\ngitlab=off\n' >"$stage"
115
- state_replace "$stage" || code=$?
116
- rm -f "$stage"
117
- return "$code"
118
- }
119
-
120
- # Host context (host KUBECONFIG) that points to the given cluster: the
121
- # cluster= line of the state expects this context, not "devzone" (services cluster)
122
- host_context_of_cluster() {
123
- local cluster="$1" host ctx
124
- host="${DEVZONE_KUBE_HOST:-$HOME/.kube/hote.config}"
125
- while IFS= read -r ctx; do
126
- [ -n "$ctx" ] || continue
127
- # The "devzone" context is set on the services cluster: we look for the
128
- # host context that points to it
129
- [ "$ctx" = devzone ] && continue
130
- if [ "$(KUBECONFIG="$host" kubectl config view -o jsonpath="{.contexts[?(@.name==\"$ctx\")].context.cluster}" 2>/dev/null || true)" = "$cluster" ]; then
131
- echo "$ctx"
132
- return 0
133
- fi
134
- done < <(KUBECONFIG="$host" kubectl config get-contexts -o name 2>/dev/null)
135
- return 1
136
- }
137
-
138
- # State missing without backup copy (#417, step 3): rebuilt from the namespaces
139
- # labelled devzone of the services cluster (module on if its namespace exists,
140
- # cluster= of the devzone context); returns 1 otherwise.
141
- state_rebuild() {
142
- local namespaces m v stage seen=0 code=0 cluster_ctx cluster_host label
143
- label="${CLUSTER_LABEL:-app.kubernetes.io/managed-by=devzone}"
144
- command -v kubectl >/dev/null 2>&1 || return 1
145
- namespaces="$(kubectl get namespaces -l "$label" -o name 2>/dev/null || true)"
146
- [ -n "$namespaces" ] || return 1
147
- stage="$(mktemp)" || return 1
148
- for m in "$@"; do
149
- v=off
150
- printf '%s\n' "$namespaces" | grep -qx "namespace/devzone-$m" && { v=on; seen=1; }
151
- printf '%s=%s\n' "$m" "$v" >>"$stage" || code=1
152
- done
153
- # devzone context -> services cluster; the cluster= expects the real host
154
- # context that points to it (e.g. docker-desktop). Without host: no line.
155
- cluster_ctx="$(kubectl config view -o jsonpath="{.contexts[?(@.name==\"devzone\")].context.cluster}" 2>/dev/null || true)"
156
- cluster_host=""
157
- if [ -n "$cluster_ctx" ]; then
158
- cluster_host="$(host_context_of_cluster "$cluster_ctx")"
159
- if [ -n "$cluster_host" ]; then
160
- printf 'cluster=%s\n' "$cluster_host" >>"$stage" || code=1
161
- fi
162
- fi
163
- if [ "$code" -eq 0 ] && [ "$seen" -eq 1 ] && state_replace "$stage"; then
164
- echo "devzone : state rebuilt from the namespaces of the services cluster: $ETAT (confirm with devzone apply)" >&2
165
- [ -n "$cluster_host" ] || echo "devzone : no host context points to the services cluster: no cluster= line in $ETAT" >&2
166
- rm -f "$stage"
167
- return 0
168
- fi
169
- rm -f "$stage"
170
- return 1
171
- }
172
-
173
- # First start (no state): former global state taken over once, otherwise backup
174
- # copy restored, otherwise state rebuilt, otherwise everything disabled
175
- state_init() {
176
- [ -f "$ETAT" ] && return 0
177
-
178
- # Migration: former global state (~/.config/devzone/modules) to the state of
179
- # the instance; moved, not copied: the first devzone started after the update
180
- # keeps its choices
181
- if [ -f "$HOME/.config/devzone/modules" ]; then
182
- if state_replace "$HOME/.config/devzone/modules"; then
183
- rm -f "$HOME/.config/devzone/modules"
184
- return 0
185
- fi
186
- fi
187
-
188
- state_lock_take || return 1
189
- if [ -f "$ETAT" ]; then
190
- state_lock_release
191
- return 0
192
- fi
193
- # 1. Backup copy left by the last write (#417)
194
- if [ -f "${ETAT}.prev" ] && state_replace "${ETAT}.prev"; then
195
- echo "devzone : state restored from the backup copy: $ETAT (confirm with devzone apply)" >&2
196
- state_recovery_mark
197
- state_lock_release
198
- return 0
199
- fi
200
- # 2. Rebuild from the services cluster (#417)
201
- if state_rebuild "$@"; then
202
- state_recovery_mark
203
- state_lock_release
204
- return 0
205
- fi
206
- # 3. First installation: everything disabled (#417)
207
- if ! state_default; then
208
- state_lock_release
209
- return 1
210
- fi
211
- state_lock_release
212
- # Connection already set up by another devzone (shared volumes): reported
213
- # once, when the state of this instance is created; stderr: init is also
214
- # called inside $(value …)
215
- if [ -f "$HOME/.claude/.credentials.json" ] || [ -f "$HOME/.local/share/opencode/auth.json" ]; then
216
- echo "devzone : shared Claude Code/opencode connection found: devzone enable ai to use it here" >&2
217
- fi
218
- return 0
219
- }
@@ -1,57 +0,0 @@
1
- #!/usr/bin/env bash
2
- # CI check: the files listed in .english must be written in English (#502).
3
- # A file fails when one of its lines contains a French accented letter or one
4
- # of the frequent French words, whole word, case-insensitive. Each fault is
5
- # printed as "path:line: text" and the run exits 1; otherwise it prints
6
- # "english check: N files ok" and exits 0. A listed file that is missing is
7
- # an error too.
8
-
9
- set -u
10
-
11
- ICI="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
12
- ROOT="$(cd "$ICI/../../.." && pwd)"
13
- LIST="$ROOT/.english"
14
-
15
- # Byte escapes and split fragments, so this file never matches its own rules
16
- # (a literal accented letter or whole word here would be reported).
17
- ACCENTS="$(printf '[\303\305][\200\202\204\206\207\210\211\212\213\216\217\222\223\224\226\231\233\234\240\242\244\246\247\250\251\252\253\256\257\264\266\270\271\273\274\277]')"
18
- WORDS="$(printf 'le_s|de_s|un_e|po_ur|av_ec|sa_ns|da_ns|fich_ier|doss_ier' | tr -d '_')"
19
- PATTERN="$ACCENTS|\\b($WORDS)\\b"
20
-
21
- # Byte matching only: the accents are matched as UTF-8 byte sequences
22
- LC_ALL=C
23
- export LC_ALL
24
-
25
- if [ ! -f "$LIST" ]; then
26
- echo "check-english: list not found: $LIST" >&2
27
- exit 1
28
- fi
29
-
30
- fails=0
31
- count=0
32
- while IFS= read -r f; do
33
- case "$f" in
34
- '' | '#'*) continue ;;
35
- esac
36
- file="$ROOT/$f"
37
- if [ ! -f "$file" ]; then
38
- echo "check-english: file listed but missing: $f" >&2
39
- fails=1
40
- continue
41
- fi
42
- count=$((count + 1))
43
- matches="$(grep -Ein -- "$PATTERN" "$file")" || matches=""
44
- while IFS= read -r m; do
45
- [ -n "$m" ] || continue
46
- n="${m%%:*}"
47
- printf '%s:%s: %s\n' "$f" "$n" "${m#*:}"
48
- fails=1
49
- done <<EOF
50
- $matches
51
- EOF
52
- done <"$LIST"
53
-
54
- if [ "$fails" -ne 0 ]; then
55
- exit 1
56
- fi
57
- echo "english check: $count files ok"