devzone 0.59.0 → 1.1.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/agent-erreurs.sh +72 -56
- package/.devcontainer/agent-etat-json.sh +45 -43
- package/.devcontainer/agent-modele.sh +3 -3
- package/.devcontainer/agent-session.sh +122 -125
- package/.devcontainer/agent-workspace.sh +53 -53
- package/.devcontainer/agent.sh +107 -109
- package/.devcontainer/argocd/argocd.sh +4 -16
- package/.devcontainer/catalogue/app.sh +1 -1
- package/.devcontainer/catalogue/catalogue-veilleur.sh +2 -2
- package/.devcontainer/catalogue/mysql/mysql.sh +1 -13
- package/.devcontainer/catalogue.sh +4 -16
- package/.devcontainer/cluster.sh +1 -1
- package/.devcontainer/command-aliases.sh +78 -114
- package/.devcontainer/devzone +34 -48
- package/.devcontainer/etat-json.sh +162 -162
- package/.devcontainer/etat-verrou.sh +25 -24
- package/.devcontainer/etat.sh +122 -123
- package/.devcontainer/gitlab/gitlab.sh +1 -13
- package/.devcontainer/gitlab/installation.sh +3 -3
- package/.devcontainer/gitlab/secrets.sh +1 -1
- package/.devcontainer/gitlab/test-gitlab.sh +1 -1
- package/.devcontainer/help.sh +4 -3
- package/.devcontainer/memoire.sh +58 -58
- package/.devcontainer/metrics-server.sh +52 -51
- package/.devcontainer/paquets.sh +0 -12
- package/.devcontainer/password.sh +88 -87
- package/.devcontainer/ports-auto.sh +6 -6
- package/.devcontainer/ports.sh +1 -13
- package/.devcontainer/postgres/postgres.sh +1 -13
- package/.devcontainer/services-admin.sh +3 -3
- package/.devcontainer/skills/devzone/SKILL.md +2 -2
- package/README.md +13 -3
- package/charts/devzone-workspace/templates/statefulset.yaml +3 -0
- package/manage/devzone +61 -569
- package/manage/scripts/argocd-services.sh +2 -2
- package/manage/scripts/devzone-create.sh +138 -0
- package/manage/scripts/devzone-manifest.sh +171 -0
- package/manage/scripts/devzone-update.sh +222 -0
- package/manage/scripts/migrer.sh +2 -6
- package/manage/scripts/workspace-aliases.sh +4 -31
- package/manage/workspace.sh +7 -12
- package/package.json +1 -1
|
@@ -1,73 +1,73 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
2
|
+
# Machine output of devzone status (--json): stable, versioned JSON object.
|
|
3
|
+
# Sourced by devzone: reuses its functions (valeur, description, …), does not
|
|
4
|
+
# rewrite etat(). Built only with jq. JSON keys are a contract: French names kept.
|
|
5
5
|
|
|
6
|
-
#
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
# Adds an entry to $errors: the section that failed and why.
|
|
7
|
+
add_error() {
|
|
8
|
+
errors="$(jq -c --arg k "$1" --arg v "$2" '. + {($k): $v}' <<<"$errors")"
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
#
|
|
12
|
-
|
|
13
|
-
local code="$1" message="$2"
|
|
14
|
-
|
|
11
|
+
# Adds an alert (code, message, devzone command to run) to $alerts_json.
|
|
12
|
+
append_alert() {
|
|
13
|
+
local code="$1" message="$2" command="${3:-}"
|
|
14
|
+
alerts_json="$(jq -c \
|
|
15
15
|
--arg code "$code" \
|
|
16
16
|
--arg message "$message" \
|
|
17
|
-
--arg
|
|
18
|
-
'. + [{code:$code,message:$message,commande:(if $
|
|
19
|
-
<<<"$
|
|
17
|
+
--arg command "$command" \
|
|
18
|
+
'. + [{code:$code,message:$message,commande:(if $command=="" then null else $command end)}]' \
|
|
19
|
+
<<<"$alerts_json")"
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
local
|
|
26
|
-
local
|
|
22
|
+
# Full state of the machine in JSON: repeats each section of etat() with the
|
|
23
|
+
# same commands, isolating each computation (failure → null value and errors).
|
|
24
|
+
state_json() {
|
|
25
|
+
local errors='{}'
|
|
26
|
+
local alerts_json='[]'
|
|
27
27
|
local dv_raw="" dvp_raw=""
|
|
28
|
-
local
|
|
29
|
-
local
|
|
30
|
-
local
|
|
31
|
-
local modules_json='[]' m
|
|
32
|
-
local
|
|
33
|
-
local services_cluster=""
|
|
34
|
-
local
|
|
35
|
-
local clusters_services_raw=""
|
|
28
|
+
local id_name="" id_email="" id_ok=false id_command=""
|
|
29
|
+
local platform_name platform_url="" github_json="null"
|
|
30
|
+
local tools_late_json='[]' tools_command=""
|
|
31
|
+
local modules_json='[]' m active desc failure_file content state_value failure_value command_value out argocd_repo=""
|
|
32
|
+
local docker_host=false docker_host_active=false relay_source
|
|
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
36
|
local ports_json='[]' ports_out
|
|
37
37
|
local applications_json='[]'
|
|
38
|
-
local
|
|
39
|
-
local
|
|
40
|
-
local
|
|
41
|
-
local
|
|
38
|
+
local credentials_raw=""
|
|
39
|
+
local late_out package frozen installed count
|
|
40
|
+
local relay_marker packages_marker packages_names n path wt_out
|
|
41
|
+
local gh_status gh_code
|
|
42
42
|
|
|
43
43
|
if v="$(version_du_dossier 2>/dev/null)"; then
|
|
44
44
|
dv_raw="$v"
|
|
45
45
|
else
|
|
46
|
-
|
|
46
|
+
add_error devzone "version_du_dossier unavailable"
|
|
47
47
|
fi
|
|
48
48
|
dvp_raw="$(version_publiee 2>/dev/null || true)"
|
|
49
49
|
|
|
50
|
-
|
|
50
|
+
id_name="$(git config --get user.name 2>/dev/null || true)"
|
|
51
51
|
id_email="$(git config --get user.email 2>/dev/null || true)"
|
|
52
|
-
if [ -n "$
|
|
52
|
+
if [ -n "$id_name" ] && [ -n "$id_email" ]; then
|
|
53
53
|
id_ok=true
|
|
54
54
|
else
|
|
55
|
-
|
|
55
|
+
id_command='gh auth login -s workflow (automatic), or git config --file ~/.config/git/config user.name "<name>" and user.email "<email>"'
|
|
56
56
|
fi
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
if [ "$
|
|
60
|
-
|
|
58
|
+
platform_name="$(plateforme_lue)"
|
|
59
|
+
if [ "$platform_name" = gitlab ]; then
|
|
60
|
+
platform_url="$(url_gitlab_lue)"
|
|
61
61
|
else
|
|
62
|
-
|
|
62
|
+
platform_url=""
|
|
63
63
|
fi
|
|
64
|
-
if [ "$
|
|
65
|
-
|
|
64
|
+
if [ "$platform_name" = github ]; then
|
|
65
|
+
gh_status="$(gh auth status 2>&1)" && gh_code=0 || gh_code=$?
|
|
66
66
|
if [ "$gh_code" -ne 0 ]; then
|
|
67
67
|
github_json="null"
|
|
68
|
-
|
|
68
|
+
add_error github "gh auth status failed"
|
|
69
69
|
else
|
|
70
|
-
if printf '%s\n' "$
|
|
70
|
+
if printf '%s\n' "$gh_status" | grep -q "Token scopes:" && ! printf '%s\n' "$gh_status" | grep -q "'workflow'"; then
|
|
71
71
|
github_json="$(jq -cn '{connecte:true,workflow:false,commande:"gh auth refresh -h github.com -s workflow"}')"
|
|
72
72
|
else
|
|
73
73
|
github_json="$(jq -cn '{connecte:true,workflow:true,commande:null}')"
|
|
@@ -77,134 +77,134 @@ etat_json() {
|
|
|
77
77
|
github_json="null"
|
|
78
78
|
fi
|
|
79
79
|
|
|
80
|
-
if
|
|
81
|
-
|
|
82
|
-
while IFS= read -r
|
|
83
|
-
[ -n "$
|
|
80
|
+
if late_out="$(outils_retard 2>/dev/null)"; then
|
|
81
|
+
tools_late_json='[]'
|
|
82
|
+
while IFS= read -r line; do
|
|
83
|
+
[ -n "$line" ] || continue
|
|
84
84
|
# shellcheck disable=SC2086
|
|
85
|
-
set -- $
|
|
86
|
-
|
|
87
|
-
[ -n "$
|
|
88
|
-
|
|
89
|
-
--arg p "$
|
|
90
|
-
'. + [{paquet:$p,figee:$f,installee:$i}]' <<<"$
|
|
91
|
-
done <<<"$
|
|
92
|
-
count="$(jq 'length' <<<"$
|
|
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
|
+
'. + [{paquet:$p,figee:$f,installee:$i}]' <<<"$tools_late_json")"
|
|
91
|
+
done <<<"$late_out"
|
|
92
|
+
count="$(jq 'length' <<<"$tools_late_json" 2>/dev/null || echo 0)"
|
|
93
93
|
if [ "$count" -gt 0 ]; then
|
|
94
|
-
|
|
94
|
+
tools_command="devzone apply"
|
|
95
95
|
fi
|
|
96
96
|
else
|
|
97
|
-
|
|
98
|
-
|
|
97
|
+
tools_late_json="null"
|
|
98
|
+
add_error outils "outils_retard unavailable"
|
|
99
99
|
fi
|
|
100
100
|
|
|
101
101
|
modules_json='[]'
|
|
102
102
|
for m in "${MODULES[@]}"; do
|
|
103
|
-
|
|
104
|
-
[ "$(valeur "$m")" = on ] &&
|
|
103
|
+
active=false
|
|
104
|
+
[ "$(valeur "$m")" = on ] && active=true
|
|
105
105
|
desc="$(description "$m")"
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
106
|
+
failure_value=""
|
|
107
|
+
state_value=""
|
|
108
|
+
command_value=""
|
|
109
109
|
if dans_pod && service_module "$m"; then
|
|
110
110
|
# Kubernetes workspace pod (#528): presence by the cluster DNS,
|
|
111
111
|
# installation from the workstation; no failure marker read here
|
|
112
112
|
if service_present "$m"; then
|
|
113
|
-
|
|
114
|
-
elif [ "$
|
|
115
|
-
|
|
116
|
-
|
|
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
117
|
else
|
|
118
|
-
|
|
119
|
-
|
|
118
|
+
state_value="optional"
|
|
119
|
+
command_value="devzone workspace services enable $m"
|
|
120
120
|
fi
|
|
121
|
-
elif [ "$
|
|
122
|
-
|
|
123
|
-
if [ -f "$
|
|
124
|
-
content="$(cat "$
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
elif [ "$active" = true ]; then
|
|
122
|
+
failure_file="$(fichier_echec "$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
128
|
elif [ "$m" = gitlab ]; then
|
|
129
|
-
if
|
|
130
|
-
|
|
129
|
+
if out="$(bash "$ICI/gitlab/gitlab.sh" status 2>/dev/null)"; then
|
|
130
|
+
state_value="$out"
|
|
131
131
|
else
|
|
132
|
-
|
|
133
|
-
|
|
132
|
+
state_value=""
|
|
133
|
+
add_error modules "gitlab.sh status unavailable"
|
|
134
134
|
fi
|
|
135
135
|
elif [ "$m" = postgres ] || [ "$m" = llm ]; then
|
|
136
|
-
if
|
|
137
|
-
|
|
136
|
+
if out="$(bash "$ICI/$m/$m.sh" status 2>/dev/null)"; then
|
|
137
|
+
state_value="$out"
|
|
138
138
|
else
|
|
139
|
-
|
|
140
|
-
|
|
139
|
+
state_value=""
|
|
140
|
+
add_error modules "$m.sh state unavailable"
|
|
141
141
|
fi
|
|
142
142
|
elif [ "$m" = argocd ]; then
|
|
143
|
-
if
|
|
144
|
-
|
|
143
|
+
if out="$(bash "$ICI/argocd/argocd.sh" status 2>/dev/null)"; then
|
|
144
|
+
state_value="$out"
|
|
145
145
|
else
|
|
146
|
-
|
|
147
|
-
|
|
146
|
+
state_value=""
|
|
147
|
+
add_error modules "argocd.sh status unavailable"
|
|
148
148
|
fi
|
|
149
149
|
elif [ "$m" = mysql ]; then
|
|
150
|
-
if
|
|
151
|
-
|
|
150
|
+
if out="$(bash "$ICI/catalogue/mysql/mysql.sh" status 2>/dev/null)"; then
|
|
151
|
+
state_value="$out"
|
|
152
152
|
else
|
|
153
|
-
|
|
154
|
-
|
|
153
|
+
state_value=""
|
|
154
|
+
add_error modules "mysql.sh status unavailable"
|
|
155
155
|
fi
|
|
156
156
|
else
|
|
157
|
-
|
|
157
|
+
state_value="active"
|
|
158
158
|
fi
|
|
159
159
|
else
|
|
160
|
-
|
|
161
|
-
|
|
160
|
+
state_value="optional"
|
|
161
|
+
command_value="devzone enable $m"
|
|
162
162
|
fi
|
|
163
163
|
modules_json="$(jq -c \
|
|
164
|
-
--arg
|
|
165
|
-
--argjson
|
|
164
|
+
--arg name "$m" \
|
|
165
|
+
--argjson active "$active" \
|
|
166
166
|
--arg description "$desc" \
|
|
167
|
-
--arg
|
|
168
|
-
--arg
|
|
169
|
-
--arg
|
|
170
|
-
'. + [{nom:$
|
|
167
|
+
--arg state "$state_value" \
|
|
168
|
+
--arg failure "$failure_value" \
|
|
169
|
+
--arg command "$command_value" \
|
|
170
|
+
'. + [{nom:$name,actif:$active,description:$description,etat:(if $state=="" then null else $state end),echec:(if $failure=="" then null else $failure end),commande:(if $command=="" then null else $command end)}]' \
|
|
171
171
|
<<<"$modules_json")"
|
|
172
172
|
done
|
|
173
173
|
|
|
174
|
-
#
|
|
175
|
-
#
|
|
174
|
+
# docker-hote option (#432): absent = on; socket really mounted (same
|
|
175
|
+
# source as docker-relais.sh), may differ until make rebuild
|
|
176
176
|
# In the Kubernetes workspace (DEVZONE_WORKSPACE=kubernetes), the pod has
|
|
177
177
|
# no Docker host socket: the socket is absent (#515)
|
|
178
178
|
if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
|
|
179
|
-
|
|
180
|
-
|
|
179
|
+
docker_host=false
|
|
180
|
+
docker_host_active=false
|
|
181
181
|
else
|
|
182
182
|
if [ "$(valeur docker-hote)" = on ]; then
|
|
183
|
-
|
|
183
|
+
docker_host=true
|
|
184
184
|
fi
|
|
185
|
-
|
|
186
|
-
if [ -e "$
|
|
187
|
-
|
|
185
|
+
relay_source="${DEVZONE_RELAIS_SOURCE:-/var/run/docker-host.sock}"
|
|
186
|
+
if [ -e "$relay_source" ]; then
|
|
187
|
+
docker_host_active=true
|
|
188
188
|
fi
|
|
189
189
|
fi
|
|
190
190
|
|
|
191
191
|
services_cluster="$(cluster_lu)"
|
|
192
192
|
if [ -n "$services_cluster" ] && ! cluster_est_local "$services_cluster"; then
|
|
193
|
-
|
|
193
|
+
services_remote=true
|
|
194
194
|
fi
|
|
195
195
|
clusters_services_raw="$services_cluster"
|
|
196
|
-
|
|
197
|
-
case "$
|
|
196
|
+
work_ctx="$(kubectl config current-context 2>/dev/null || true)"
|
|
197
|
+
case "$work_ctx" in
|
|
198
198
|
kind-gitlab* | kind-devzone*)
|
|
199
|
-
|
|
200
|
-
if [ -n "$
|
|
201
|
-
|
|
199
|
+
host_ctx="$(KUBECONFIG="${DEVZONE_KUBE_HOTE:-$HOME/.kube/hote.config}" kubectl config current-context 2>/dev/null || true)"
|
|
200
|
+
if [ -n "$host_ctx" ] && cluster_joignable "$host_ctx" 2>/dev/null; then
|
|
201
|
+
work_internal=true
|
|
202
202
|
fi
|
|
203
203
|
;;
|
|
204
204
|
esac
|
|
205
|
-
|
|
206
|
-
if [ "$
|
|
207
|
-
|
|
205
|
+
clusters_work_raw="$work_ctx"
|
|
206
|
+
if [ "$work_internal" = true ]; then
|
|
207
|
+
clusters_command="devzone use $host_ctx"
|
|
208
208
|
fi
|
|
209
209
|
|
|
210
210
|
if ports_out="$(bash "$ICI/ports.sh" list --json 2>/dev/null)"; then
|
|
@@ -212,47 +212,47 @@ etat_json() {
|
|
|
212
212
|
ports_json="$ports_out"
|
|
213
213
|
else
|
|
214
214
|
ports_json="null"
|
|
215
|
-
|
|
215
|
+
add_error ports "ports output unreadable"
|
|
216
216
|
fi
|
|
217
217
|
else
|
|
218
218
|
ports_json="null"
|
|
219
|
-
|
|
219
|
+
add_error ports "ports.sh unavailable"
|
|
220
220
|
fi
|
|
221
221
|
|
|
222
222
|
applications_json="$(bash "$ICI/catalogue.sh" json 2>/dev/null || echo '[]')"
|
|
223
223
|
if ! printf '%s' "$applications_json" | jq -e . >/dev/null 2>&1; then
|
|
224
224
|
applications_json='[]'
|
|
225
|
-
|
|
225
|
+
add_error modules "catalogue.sh json unavailable"
|
|
226
226
|
fi
|
|
227
227
|
|
|
228
228
|
if [ -f "$RACINE/.password" ]; then
|
|
229
|
-
|
|
229
|
+
credentials_raw="$RACINE/.password"
|
|
230
230
|
fi
|
|
231
231
|
|
|
232
|
-
|
|
233
|
-
if [ -f "$
|
|
234
|
-
msg="$(head -1 "$
|
|
235
|
-
|
|
232
|
+
relay_marker="${DEVZONE_RELAIS_MARQUE:-/tmp/devzone-relais-docker.echec}"
|
|
233
|
+
if [ -f "$relay_marker" ]; then
|
|
234
|
+
msg="$(head -1 "$relay_marker" 2>/dev/null || true)"
|
|
235
|
+
append_alert relais_docker "$msg" "devzone repair"
|
|
236
236
|
fi
|
|
237
|
-
|
|
238
|
-
if [ -f "$
|
|
239
|
-
|
|
237
|
+
packages_marker="${DEVZONE_PAQUETS_MARQUE:-/tmp/devzone-paquets.echec}"
|
|
238
|
+
if [ -f "$packages_marker" ]; then
|
|
239
|
+
packages_names=""
|
|
240
240
|
while IFS= read -r n; do
|
|
241
241
|
[ -n "$n" ] || continue
|
|
242
|
-
|
|
243
|
-
done < "$
|
|
244
|
-
|
|
242
|
+
packages_names="${packages_names:+$packages_names, }$n"
|
|
243
|
+
done < "$packages_marker"
|
|
244
|
+
append_alert paquets "$packages_names" "devzone packages"
|
|
245
245
|
fi
|
|
246
246
|
wt_out="$(worktrees_absents 2>/dev/null || true)"
|
|
247
|
-
while IFS= read -r
|
|
248
|
-
[ -n "$
|
|
249
|
-
|
|
247
|
+
while IFS= read -r path; do
|
|
248
|
+
[ -n "$path" ] || continue
|
|
249
|
+
append_alert worktree "$path missing here (created outside the container?)" ""
|
|
250
250
|
done <<<"$wt_out"
|
|
251
251
|
if [ -n "$services_cluster" ] && ! cluster_est_local "$services_cluster"; then
|
|
252
|
-
|
|
252
|
+
append_alert cluster_distant "remote cluster: $services_cluster — services on a remote cluster" ""
|
|
253
253
|
fi
|
|
254
|
-
if [ "$
|
|
255
|
-
|
|
254
|
+
if [ "$work_internal" = true ]; then
|
|
255
|
+
append_alert cluster_interne "work cluster: $work_ctx (devzone internal cluster)" "devzone use $host_ctx"
|
|
256
256
|
fi
|
|
257
257
|
|
|
258
258
|
argocd_repo="$(conf_get argocd repo)"
|
|
@@ -262,47 +262,47 @@ etat_json() {
|
|
|
262
262
|
--arg dv "$dv_raw" \
|
|
263
263
|
--arg dvp "$dvp_raw" \
|
|
264
264
|
--argjson id_ok "$id_ok" \
|
|
265
|
-
--arg
|
|
265
|
+
--arg id_name "$id_name" \
|
|
266
266
|
--arg id_email "$id_email" \
|
|
267
|
-
--arg
|
|
268
|
-
--arg
|
|
269
|
-
--arg
|
|
267
|
+
--arg id_command "$id_command" \
|
|
268
|
+
--arg platform_name "$platform_name" \
|
|
269
|
+
--arg platform_url "$platform_url" \
|
|
270
270
|
--argjson github "$github_json" \
|
|
271
|
-
--argjson
|
|
272
|
-
--arg
|
|
271
|
+
--argjson tools_late "$tools_late_json" \
|
|
272
|
+
--arg tools_command "$tools_command" \
|
|
273
273
|
--argjson modules "$modules_json" \
|
|
274
274
|
--arg argocd_repo "$argocd_repo" \
|
|
275
|
-
--argjson
|
|
276
|
-
--argjson
|
|
275
|
+
--argjson docker_host "$docker_host" \
|
|
276
|
+
--argjson docker_host_active "$docker_host_active" \
|
|
277
277
|
--arg clusters_services "$clusters_services_raw" \
|
|
278
|
-
--argjson
|
|
279
|
-
--arg
|
|
280
|
-
--argjson
|
|
281
|
-
--arg
|
|
278
|
+
--argjson services_remote "$services_remote" \
|
|
279
|
+
--arg clusters_work "$clusters_work_raw" \
|
|
280
|
+
--argjson work_internal "$work_internal" \
|
|
281
|
+
--arg clusters_command "$clusters_command" \
|
|
282
282
|
--argjson ports "$ports_json" \
|
|
283
283
|
--argjson applications "$applications_json" \
|
|
284
|
-
--arg
|
|
285
|
-
--argjson
|
|
286
|
-
--argjson
|
|
284
|
+
--arg credentials "$credentials_raw" \
|
|
285
|
+
--argjson alerts "$alerts_json" \
|
|
286
|
+
--argjson errors "$errors" \
|
|
287
287
|
'{
|
|
288
288
|
schema: $schema,
|
|
289
289
|
devzone: { version: (if $dv=="" then null else $dv end), disponible: (if $dvp=="" then null else $dvp end) },
|
|
290
|
-
identite_git: { ok: $id_ok, nom: (if $
|
|
291
|
-
plateforme: { nom: $
|
|
290
|
+
identite_git: { ok: $id_ok, nom: (if $id_name=="" then null else $id_name end), email: (if $id_email=="" then null else $id_email end), commande: (if $id_command=="" then null else $id_command end) },
|
|
291
|
+
plateforme: { nom: $platform_name, url: (if $platform_url=="" then null else $platform_url end), github: $github },
|
|
292
292
|
argocd_repo: (if $argocd_repo == "" then null else $argocd_repo end),
|
|
293
|
-
outils: { retards: $
|
|
293
|
+
outils: { retards: $tools_late, commande: (if $tools_command=="" then null else $tools_command end) },
|
|
294
294
|
modules: $modules,
|
|
295
|
-
docker_hote: $
|
|
296
|
-
docker_hote_actif: $
|
|
297
|
-
clusters: { services: (if $clusters_services=="" then null else $clusters_services end), services_distant: $
|
|
295
|
+
docker_hote: $docker_host,
|
|
296
|
+
docker_hote_actif: $docker_host_active,
|
|
297
|
+
clusters: { services: (if $clusters_services=="" then null else $clusters_services end), services_distant: $services_remote, travail: (if $clusters_work=="" then null else $clusters_work end), travail_interne: $work_internal, commande: (if $clusters_command=="" then null else $clusters_command end) },
|
|
298
298
|
ports: $ports,
|
|
299
299
|
applications: (if $applications=="" then null else $applications end),
|
|
300
|
-
identifiants: (if $
|
|
301
|
-
alertes: $
|
|
302
|
-
erreurs: $
|
|
300
|
+
identifiants: (if $credentials=="" then null else $credentials end),
|
|
301
|
+
alertes: $alerts,
|
|
302
|
+
erreurs: $errors
|
|
303
303
|
}'
|
|
304
304
|
}
|
|
305
305
|
|
|
306
306
|
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
|
307
|
-
|
|
307
|
+
state_json
|
|
308
308
|
fi
|
|
@@ -1,52 +1,53 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
2
|
+
# Write lock of the module state, sourced by etat.sh (#417 and #476)
|
|
3
|
+
# state_lock_take / state_lock_release write lock
|
|
4
4
|
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
|
|
9
|
-
local age
|
|
10
|
-
[ "${
|
|
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
11
|
mkdir -p "$(dirname "$ETAT")" || return 1
|
|
12
|
-
|
|
12
|
+
start="$(date +%s)"
|
|
13
13
|
while ! mkdir "${ETAT}.verrou" 2>/dev/null; do
|
|
14
14
|
age="$(stat -c %Y "${ETAT}.verrou" 2>/dev/null || stat -f %m "${ETAT}.verrou" 2>/dev/null || true)"
|
|
15
15
|
if [ -n "$age" ] && [ "$(( $(date +%s) - age ))" -gt 30 ]; then
|
|
16
16
|
rm -rf "${ETAT}.verrou"
|
|
17
17
|
continue
|
|
18
18
|
fi
|
|
19
|
-
if [ "$(( $(date +%s) -
|
|
20
|
-
echo "devzone :
|
|
19
|
+
if [ "$(( $(date +%s) - start ))" -ge 10 ]; then
|
|
20
|
+
echo "devzone : state locked elsewhere: ${ETAT}.verrou" >&2
|
|
21
21
|
return 1
|
|
22
22
|
fi
|
|
23
23
|
sleep 1
|
|
24
24
|
done
|
|
25
|
-
# flock
|
|
25
|
+
# flock serializes the write when it exists (Linux); mkdir stays the only
|
|
26
|
+
# guard on macOS (#476, same pattern as #461).
|
|
26
27
|
if command -v flock >/dev/null 2>&1; then
|
|
27
28
|
if { exec 8>"${ETAT}.lock"; } && flock -w 10 8; then
|
|
28
|
-
|
|
29
|
+
STATE_LOCK_FLOCK=1
|
|
29
30
|
else
|
|
30
31
|
rm -rf "${ETAT}.verrou" 2>/dev/null || true
|
|
31
|
-
echo "devzone :
|
|
32
|
+
echo "devzone : state locked elsewhere (flock): ${ETAT}.lock" >&2
|
|
32
33
|
return 1
|
|
33
34
|
fi
|
|
34
35
|
fi
|
|
35
|
-
|
|
36
|
+
STATE_LOCK_DEPTH=1
|
|
36
37
|
return 0
|
|
37
38
|
}
|
|
38
39
|
|
|
39
|
-
#
|
|
40
|
-
|
|
41
|
-
local
|
|
42
|
-
[ "$
|
|
43
|
-
[ "$
|
|
44
|
-
|
|
45
|
-
if [ "${
|
|
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
|
|
46
47
|
flock -u 8 2>/dev/null || true
|
|
47
48
|
exec 8>&-
|
|
48
|
-
|
|
49
|
+
STATE_LOCK_FLOCK=0
|
|
49
50
|
fi
|
|
50
51
|
rm -rf "${ETAT}.verrou" 2>/dev/null || true
|
|
51
52
|
return 0
|
|
52
|
-
}
|
|
53
|
+
}
|