devzone 1.0.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 -4
- package/.devcontainer/catalogue/app.sh +1 -1
- package/.devcontainer/catalogue/catalogue-veilleur.sh +2 -2
- package/.devcontainer/catalogue/mysql/mysql.sh +1 -1
- package/.devcontainer/catalogue.sh +3 -3
- package/.devcontainer/cluster.sh +1 -1
- package/.devcontainer/devzone +14 -13
- 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 -1
- package/.devcontainer/gitlab/installation.sh +3 -3
- package/.devcontainer/gitlab/secrets.sh +1 -1
- package/.devcontainer/help.sh +1 -0
- package/.devcontainer/memoire.sh +58 -58
- package/.devcontainer/metrics-server.sh +52 -51
- package/.devcontainer/password.sh +88 -87
- package/.devcontainer/ports-auto.sh +6 -6
- package/.devcontainer/ports.sh +1 -1
- package/.devcontainer/postgres/postgres.sh +1 -1
- package/.devcontainer/services-admin.sh +3 -3
- package/README.md +2 -2
- package/charts/devzone-workspace/templates/statefulset.yaml +3 -0
- package/package.json +1 -1
|
@@ -1,99 +1,100 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
# Usage
|
|
5
|
-
# (
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
2
|
+
# Installs metrics-server (CPU/RAM in k9s, kubectl top) on the clusters that
|
|
3
|
+
# have no Metrics API. Docker Desktop and kind do not have it by default.
|
|
4
|
+
# Usage: metrics-server.sh [context...] | metrics-server.sh retirer [context...]
|
|
5
|
+
# (default: reachable local clusters; retirer, the public subcommand
|
|
6
|
+
# name kept as is: removal from the clusters where devzone installed it)
|
|
7
|
+
# --kubelet-insecure-tls: the kubelet of Docker Desktop and kind has a
|
|
8
|
+
# self-signed certificate, without this option the pod never becomes Ready.
|
|
9
|
+
# Exits in error if a requested context is unknown or unreachable, or if an
|
|
10
|
+
# installation fails (kube-config.sh calls it with || true).
|
|
10
11
|
set -euo pipefail
|
|
11
12
|
|
|
12
13
|
# shellcheck source=SCRIPTDIR/cluster.sh
|
|
13
14
|
. "$(dirname "$0")/cluster.sh"
|
|
14
15
|
|
|
15
16
|
VERSION=v0.9.0
|
|
16
|
-
|
|
17
|
+
MANIFEST="https://github.com/kubernetes-sigs/metrics-server/releases/download/${VERSION}/components.yaml"
|
|
17
18
|
|
|
18
|
-
mapfile -t
|
|
19
|
+
mapfile -t known < <(kubectl config get-contexts -o name 2>/dev/null || true)
|
|
19
20
|
|
|
20
21
|
if [ "${1:-}" = retirer ]; then
|
|
21
22
|
shift
|
|
22
|
-
#
|
|
23
|
-
#
|
|
24
|
-
|
|
25
|
-
if [ "$
|
|
26
|
-
#
|
|
27
|
-
#
|
|
28
|
-
mapfile -t
|
|
23
|
+
# Removal (kubernetes module disabled): only the contexts where devzone
|
|
24
|
+
# installed metrics-server (devzone=installe mark) are removed
|
|
25
|
+
requested=$#
|
|
26
|
+
if [ "$requested" -eq 0 ]; then
|
|
27
|
+
# Local clusters only: removal on a remote cluster has nothing to remove
|
|
28
|
+
# (devzone never installs there)
|
|
29
|
+
mapfile -t contexts < <(printf '%s\n' ${known[@]+"${known[@]}"} |
|
|
29
30
|
while IFS= read -r c; do cluster_est_local "$c" && echo "$c"; done || true)
|
|
30
|
-
set -- ${
|
|
31
|
+
set -- ${contexts[@]+"${contexts[@]}"}
|
|
31
32
|
fi
|
|
32
33
|
code=0
|
|
33
|
-
for
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
|
|
34
|
+
for context in "$@"; do
|
|
35
|
+
# Mark read on the deployment by its name: kubectl refuses a name with
|
|
36
|
+
# a selector (-l), the test would always be false (#255)
|
|
37
|
+
mark="$(kubectl --context "$context" -n kube-system get deployment metrics-server \
|
|
37
38
|
-o jsonpath='{.metadata.labels.devzone}' 2>/dev/null || true)"
|
|
38
|
-
if [ "$
|
|
39
|
-
if kubectl --context "$
|
|
40
|
-
echo "metrics-server
|
|
39
|
+
if [ "$mark" = installe ]; then
|
|
40
|
+
if kubectl --context "$context" delete -f "$MANIFEST" --ignore-not-found >/dev/null 2>&1; then
|
|
41
|
+
echo "metrics-server removed ($VERSION) : $context"
|
|
41
42
|
else
|
|
42
|
-
echo "metrics-server :
|
|
43
|
+
echo "metrics-server : removal failed: $context" >&2
|
|
43
44
|
code=1
|
|
44
45
|
fi
|
|
45
|
-
elif kubectl --context "$
|
|
46
|
-
#
|
|
47
|
-
echo "metrics-server
|
|
46
|
+
elif kubectl --context "$context" -n kube-system get deployment metrics-server >/dev/null 2>&1; then
|
|
47
|
+
# Installed by someone else: not up to devzone to remove it
|
|
48
|
+
echo "metrics-server present without a devzone mark, left: $context" >&2
|
|
48
49
|
fi
|
|
49
50
|
done
|
|
50
51
|
exit "$code"
|
|
51
52
|
fi
|
|
52
53
|
|
|
53
|
-
|
|
54
|
-
if [ "$
|
|
55
|
-
#
|
|
56
|
-
#
|
|
57
|
-
mapfile -t
|
|
54
|
+
requested=$#
|
|
55
|
+
if [ "$requested" -eq 0 ]; then
|
|
56
|
+
# Local clusters only: never an automatic installation on a remote cluster
|
|
57
|
+
# of the host (prod, staging…); for another one, name it as an argument
|
|
58
|
+
mapfile -t contexts < <(printf '%s\n' ${known[@]+"${known[@]}"} |
|
|
58
59
|
while IFS= read -r c; do cluster_est_local "$c" && echo "$c"; done || true)
|
|
59
|
-
set -- ${
|
|
60
|
+
set -- ${contexts[@]+"${contexts[@]}"}
|
|
60
61
|
fi
|
|
61
62
|
|
|
62
63
|
code=0
|
|
63
|
-
|
|
64
|
-
for
|
|
65
|
-
if [ "$
|
|
66
|
-
echo "metrics-server :
|
|
64
|
+
reachable=0
|
|
65
|
+
for context in "$@"; do
|
|
66
|
+
if [ "$requested" -gt 0 ] && ! printf '%s\n' ${known[@]+"${known[@]}"} | grep -qxF -- "$context"; then
|
|
67
|
+
echo "metrics-server : unknown context: $context (see kubectl config get-contexts)" >&2
|
|
67
68
|
code=1
|
|
68
69
|
continue
|
|
69
70
|
fi
|
|
70
|
-
k=(kubectl --context "$
|
|
71
|
+
k=(kubectl --context "$context" --request-timeout=5s)
|
|
71
72
|
if ! "${k[@]}" get --raw /readyz >/dev/null 2>&1; then
|
|
72
|
-
#
|
|
73
|
-
if [ "$
|
|
74
|
-
echo "metrics-server : cluster
|
|
73
|
+
# Without argument: kind may still be starting, ignored
|
|
74
|
+
if [ "$requested" -gt 0 ]; then
|
|
75
|
+
echo "metrics-server : cluster unreachable: $context" >&2
|
|
75
76
|
code=1
|
|
76
77
|
fi
|
|
77
78
|
continue
|
|
78
79
|
fi
|
|
79
|
-
|
|
80
|
+
reachable=$((reachable + 1))
|
|
80
81
|
if "${k[@]}" get apiservice v1beta1.metrics.k8s.io >/dev/null 2>&1; then
|
|
81
|
-
echo "metrics-server :
|
|
82
|
+
echo "metrics-server : already present: $context"
|
|
82
83
|
continue
|
|
83
84
|
fi
|
|
84
|
-
if "${k[@]}" apply -f "$
|
|
85
|
+
if "${k[@]}" apply -f "$MANIFEST" >/dev/null &&
|
|
85
86
|
"${k[@]}" -n kube-system patch deployment metrics-server --type=json \
|
|
86
87
|
-p '[{"op":"add","path":"/spec/template/spec/containers/0/args/-","value":"--kubelet-insecure-tls"}]' >/dev/null &&
|
|
87
|
-
#
|
|
88
|
+
# Mark: make desinstaller only removes what devzone installed
|
|
88
89
|
"${k[@]}" -n kube-system label deployment metrics-server devzone=installe app.kubernetes.io/managed-by=devzone --overwrite >/dev/null; then
|
|
89
|
-
echo "metrics-server :
|
|
90
|
+
echo "metrics-server : installed ($VERSION): $context (metrics within ~1 min)"
|
|
90
91
|
else
|
|
91
|
-
echo "metrics-server :
|
|
92
|
+
echo "metrics-server : installation failed: $context" >&2
|
|
92
93
|
code=1
|
|
93
94
|
fi
|
|
94
95
|
done
|
|
95
96
|
|
|
96
|
-
if [ "$
|
|
97
|
-
echo "metrics-server :
|
|
97
|
+
if [ "$requested" -eq 0 ] && [ "$reachable" -eq 0 ]; then
|
|
98
|
+
echo "metrics-server : no reachable local cluster; after kind create cluster: bash .devcontainer/metrics-server.sh"
|
|
98
99
|
fi
|
|
99
100
|
exit "$code"
|
|
@@ -1,145 +1,146 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
# password.sh regenerer
|
|
4
|
-
# password.sh chemin
|
|
5
|
-
#
|
|
6
|
-
#
|
|
2
|
+
# Grouped credentials of the accounts created by devzone (#332).
|
|
3
|
+
# password.sh regenerer reads the module files, writes $ROOT/.password
|
|
4
|
+
# password.sh chemin prints the path of $ROOT/.password
|
|
5
|
+
# The module files stay the source: .password is a regenerated view.
|
|
6
|
+
# Plain-text secrets: never printed, never committed (.gitignore), mode 600.
|
|
7
|
+
# (regenerer and chemin are public subcommand names, kept as they are.)
|
|
7
8
|
set -euo pipefail
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
PASSWORD_HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
11
|
+
PASSWORD_ROOT="${DEVZONE_RACINE:-$(dirname "$PASSWORD_HERE")}"
|
|
12
|
+
PASSWORD_TARGET="$PASSWORD_ROOT/.password"
|
|
12
13
|
|
|
13
|
-
#
|
|
14
|
-
# workspace/.
|
|
15
|
-
#
|
|
16
|
-
|
|
14
|
+
# Regenerates $ROOT/.password from workspace/.gitlab, workspace/.postgres,
|
|
15
|
+
# workspace/.argocd, workspace/.mysql and the other workspace/.<app>/ folders.
|
|
16
|
+
# Silent on success; without any account, the file is removed.
|
|
17
|
+
password_regenerate() (
|
|
17
18
|
umask 077
|
|
18
|
-
local
|
|
19
|
-
local gl="$
|
|
20
|
-
local ar="$
|
|
21
|
-
local my="$
|
|
22
|
-
local tab
|
|
19
|
+
local target="$PASSWORD_TARGET" root="$PASSWORD_ROOT"
|
|
20
|
+
local gl="$root/workspace/.gitlab" pg="$root/workspace/.postgres"
|
|
21
|
+
local ar="$root/workspace/.argocd"
|
|
22
|
+
local my="$root/workspace/.mysql"
|
|
23
|
+
local tab entries tmp file name service address user secret
|
|
23
24
|
tab="$(printf '\t')"
|
|
24
|
-
|
|
25
|
+
entries="$(mktemp "$root/.password.entries.XXXXXX")" || return 1
|
|
25
26
|
tmp=""
|
|
26
27
|
|
|
27
28
|
if [ -s "$gl/root-password" ]; then
|
|
28
|
-
|
|
29
|
-
if [ -n "$
|
|
30
|
-
printf 'gitlab\t%s\troot\t%s\n' "http://gitlab.localhost:8929" "$
|
|
29
|
+
secret="$(cat "$gl/root-password")"
|
|
30
|
+
if [ -n "$secret" ]; then
|
|
31
|
+
printf 'gitlab\t%s\troot\t%s\n' "http://gitlab.localhost:8929" "$secret" >>"$entries"
|
|
31
32
|
fi
|
|
32
33
|
fi
|
|
33
34
|
if [ -s "$gl/dev-password" ]; then
|
|
34
|
-
|
|
35
|
-
if [ -n "$
|
|
36
|
-
printf 'gitlab\t%s\tdev\t%s\n' "http://gitlab.localhost:8929" "$
|
|
35
|
+
secret="$(cat "$gl/dev-password")"
|
|
36
|
+
if [ -n "$secret" ]; then
|
|
37
|
+
printf 'gitlab\t%s\tdev\t%s\n' "http://gitlab.localhost:8929" "$secret" >>"$entries"
|
|
37
38
|
fi
|
|
38
39
|
fi
|
|
39
40
|
if [ -s "$pg/admin-password" ]; then
|
|
40
|
-
|
|
41
|
-
if [ -n "$
|
|
42
|
-
printf 'postgres\t%s\tpostgres\t%s\n' "127.0.0.1:5432" "$
|
|
41
|
+
secret="$(cat "$pg/admin-password")"
|
|
42
|
+
if [ -n "$secret" ]; then
|
|
43
|
+
printf 'postgres\t%s\tpostgres\t%s\n' "127.0.0.1:5432" "$secret" >>"$entries"
|
|
43
44
|
fi
|
|
44
45
|
fi
|
|
45
|
-
# MySQL root
|
|
46
|
+
# Catalogue MySQL root (direct helm or Argo CD, #538): mirror of the workstation
|
|
46
47
|
if [ -s "$my/admin-password" ]; then
|
|
47
|
-
|
|
48
|
-
if [ -n "$
|
|
49
|
-
printf 'mysql\t%s\troot\t%s\n' "127.0.0.1:3306" "$
|
|
48
|
+
secret="$(cat "$my/admin-password")"
|
|
49
|
+
if [ -n "$secret" ]; then
|
|
50
|
+
printf 'mysql\t%s\troot\t%s\n' "127.0.0.1:3306" "$secret" >>"$entries"
|
|
50
51
|
fi
|
|
51
52
|
fi
|
|
52
53
|
if [ -s "$ar/admin.env" ]; then
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
if [ -n "$
|
|
56
|
-
printf 'argocd\t%s\t%s\t%s\n' "https://127.0.0.1:8443" "$
|
|
54
|
+
user="$(sed -n 's/^ARGOCD_USER=//p' "$ar/admin.env" 2>/dev/null | tail -1 || true)"
|
|
55
|
+
secret="$(sed -n 's/^ARGOCD_PASSWORD=//p' "$ar/admin.env" 2>/dev/null | tail -1 || true)"
|
|
56
|
+
if [ -n "$user" ] && [ -n "$secret" ]; then
|
|
57
|
+
printf 'argocd\t%s\t%s\t%s\n' "https://127.0.0.1:8443" "$user" "$secret" >>"$entries"
|
|
57
58
|
fi
|
|
58
59
|
fi
|
|
59
|
-
for
|
|
60
|
-
[ -f "$
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
service="postgres:$
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
if [ -z "$
|
|
60
|
+
for file in "$pg"/*.env; do
|
|
61
|
+
[ -f "$file" ] || continue
|
|
62
|
+
name="${file##*/}"
|
|
63
|
+
name="${name%.env}"
|
|
64
|
+
service="postgres:$name"
|
|
65
|
+
user="$(sed -n 's/^DB_USER=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
66
|
+
secret="$(sed -n 's/^DB_PASSWORD=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
67
|
+
address="$(sed -n 's/^DB_NAME=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
68
|
+
if [ -z "$user" ] || [ -z "$secret" ]; then
|
|
68
69
|
continue
|
|
69
70
|
fi
|
|
70
|
-
|
|
71
|
-
printf '%s\t%s\t%s\t%s\n' "$service" "$
|
|
71
|
+
address="127.0.0.1:5432/${address:-$name}"
|
|
72
|
+
printf '%s\t%s\t%s\t%s\n' "$service" "$address" "$user" "$secret" >>"$entries"
|
|
72
73
|
done
|
|
73
|
-
#
|
|
74
|
-
# <APP>
|
|
75
|
-
for
|
|
76
|
-
[ -d "$
|
|
77
|
-
app="${
|
|
74
|
+
# Each other catalogue application: workspace/.<app>/*.env, keys <APP>_HOST,
|
|
75
|
+
# <APP>_PORT, <APP>_USER, <APP>_PASSWORD (or MYSQL_* for mysql)
|
|
76
|
+
for dir in "$root"/workspace/.*/; do
|
|
77
|
+
[ -d "$dir" ] || continue
|
|
78
|
+
app="${dir%/}"
|
|
78
79
|
app="${app##*/}"
|
|
79
80
|
case "$app" in . | .. | .gitlab | .postgres | .argocd) continue ;; esac
|
|
80
81
|
app="${app#.}"
|
|
81
|
-
|
|
82
|
-
for
|
|
83
|
-
[ -f "$
|
|
84
|
-
base="${
|
|
82
|
+
app_upper="$(printf '%s' "$app" | tr '[:lower:]' '[:upper:]')"
|
|
83
|
+
for file in "$dir"*.env; do
|
|
84
|
+
[ -f "$file" ] || continue
|
|
85
|
+
base="${file##*/}"
|
|
85
86
|
base="${base%.env}"
|
|
86
|
-
|
|
87
|
-
[ -z "$
|
|
88
|
-
[ -z "$
|
|
89
|
-
|
|
90
|
-
[ -z "$
|
|
91
|
-
[ -z "$
|
|
92
|
-
[ -z "$
|
|
93
|
-
|
|
94
|
-
[ -z "$
|
|
95
|
-
[ -z "$
|
|
96
|
-
[ -z "$
|
|
97
|
-
port="$(sed -n "s/^${
|
|
98
|
-
[ -z "$port" ] && port="$(sed -n 's/^DB_PORT=//p' "$
|
|
99
|
-
[ -z "$port" ] && port="$(sed -n 's/^MYSQL_PORT=//p' "$
|
|
87
|
+
user="$(sed -n "s/^${app_upper}_USER=//p" "$file" 2>/dev/null | tail -1 || true)"
|
|
88
|
+
[ -z "$user" ] && user="$(sed -n 's/^DB_USER=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
89
|
+
[ -z "$user" ] && user="$(sed -n 's/^MYSQL_USER=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
90
|
+
secret="$(sed -n "s/^${app_upper}_PASSWORD=//p" "$file" 2>/dev/null | tail -1 || true)"
|
|
91
|
+
[ -z "$secret" ] && secret="$(sed -n 's/^DB_PASSWORD=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
92
|
+
[ -z "$secret" ] && secret="$(sed -n 's/^MYSQL_PASSWORD=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
93
|
+
[ -z "$user" ] || [ -z "$secret" ] && continue
|
|
94
|
+
host="$(sed -n "s/^${app_upper}_HOST=//p" "$file" 2>/dev/null | tail -1 || true)"
|
|
95
|
+
[ -z "$host" ] && host="$(sed -n 's/^DB_HOST=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
96
|
+
[ -z "$host" ] && host="$(sed -n 's/^MYSQL_HOST=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
97
|
+
[ -z "$host" ] && host=127.0.0.1
|
|
98
|
+
port="$(sed -n "s/^${app_upper}_PORT=//p" "$file" 2>/dev/null | tail -1 || true)"
|
|
99
|
+
[ -z "$port" ] && port="$(sed -n 's/^DB_PORT=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
100
|
+
[ -z "$port" ] && port="$(sed -n 's/^MYSQL_PORT=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
100
101
|
[ -z "$port" ] && port=3306
|
|
101
|
-
printf '%s\t%s\t%s\t%s\n' "$app:$base" "$
|
|
102
|
+
printf '%s\t%s\t%s\t%s\n' "$app:$base" "$host:$port" "$user" "$secret" >>"$entries"
|
|
102
103
|
done
|
|
103
104
|
done
|
|
104
105
|
|
|
105
|
-
if [ ! -s "$
|
|
106
|
-
rm -f "$
|
|
106
|
+
if [ ! -s "$entries" ]; then
|
|
107
|
+
rm -f "$entries" "$target"
|
|
107
108
|
return 0
|
|
108
109
|
fi
|
|
109
110
|
|
|
110
|
-
tmp="$(mktemp "$
|
|
111
|
-
rm -f "$
|
|
111
|
+
tmp="$(mktemp "$root/.password.XXXXXX")" || {
|
|
112
|
+
rm -f "$entries"
|
|
112
113
|
return 1
|
|
113
114
|
}
|
|
114
115
|
{
|
|
115
116
|
printf '%s\n' \
|
|
116
|
-
'# devzone :
|
|
117
|
-
'#
|
|
118
|
-
"# service${tab}
|
|
119
|
-
LC_ALL=C sort -t "$tab" -k1,1 -k3,3 "$
|
|
117
|
+
'# devzone : identifiers of the accounts created by devzone. Plain-text secrets:' \
|
|
118
|
+
'# never commit, copy or paste them into a ticket. Regenerated by devzone.' \
|
|
119
|
+
"# service${tab}address${tab}user${tab}password"
|
|
120
|
+
LC_ALL=C sort -t "$tab" -k1,1 -k3,3 "$entries"
|
|
120
121
|
} >"$tmp" || {
|
|
121
|
-
rm -f "$
|
|
122
|
+
rm -f "$entries" "$tmp"
|
|
122
123
|
return 1
|
|
123
124
|
}
|
|
124
125
|
chmod 600 "$tmp" || {
|
|
125
|
-
rm -f "$
|
|
126
|
+
rm -f "$entries" "$tmp"
|
|
126
127
|
return 1
|
|
127
128
|
}
|
|
128
|
-
mv "$tmp" "$
|
|
129
|
-
rm -f "$
|
|
129
|
+
mv "$tmp" "$target" || {
|
|
130
|
+
rm -f "$entries" "$tmp"
|
|
130
131
|
return 1
|
|
131
132
|
}
|
|
132
|
-
chmod 600 "$
|
|
133
|
-
rm -f "$
|
|
133
|
+
chmod 600 "$target" || {
|
|
134
|
+
rm -f "$entries"
|
|
134
135
|
return 1
|
|
135
136
|
}
|
|
136
|
-
rm -f "$
|
|
137
|
+
rm -f "$entries"
|
|
137
138
|
)
|
|
138
139
|
|
|
139
140
|
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
|
140
141
|
case "${1:-}" in
|
|
141
|
-
regenerer)
|
|
142
|
-
chemin) printf '%s\n' "$
|
|
142
|
+
regenerer) password_regenerate ;;
|
|
143
|
+
chemin) printf '%s\n' "$PASSWORD_TARGET" ;;
|
|
143
144
|
*)
|
|
144
145
|
echo "devzone : password.sh : regenerer | chemin" >&2
|
|
145
146
|
exit 1
|
|
@@ -18,7 +18,7 @@ ports_auto_actif() { local v; v="$(grep -E '^ports_auto=' "$ETAT" 2>/dev/null |
|
|
|
18
18
|
# Liste des ports exclus par l'utilisateur (ports_exclus=, virgules).
|
|
19
19
|
ports_exclus_lus() { grep -E '^ports_exclus=' "$ETAT" 2>/dev/null | tail -1 | cut -d= -f2- || true; }
|
|
20
20
|
# Ecrit une ligne cle=valeur dans l'etat, comme ecrire_ports pour ports=
|
|
21
|
-
ecrire() {
|
|
21
|
+
ecrire() { state_write "$1" "${2:-}" || { echo "devzone : port : etat non enregistre : $ETAT" >&2; return 1; }; }
|
|
22
22
|
# Un port est exclu quand il figure dans la liste ports_exclus=.
|
|
23
23
|
port_exclu() { case ",$(ports_exclus_lus)," in *",$1,"*) return 0 ;; esac; return 1; }
|
|
24
24
|
# Nom du relais automatique d'un port : devzone-<instance>-auto-<port>.
|
|
@@ -87,10 +87,10 @@ verrou_rafraichir() { touch "$VERROU" 2>/dev/null || true; echo "$$" >"$VERROU/p
|
|
|
87
87
|
ports_auto_tour() {
|
|
88
88
|
local port now delay sortie
|
|
89
89
|
# État restauré ou reconstruit : rien pendant 60 s (#417, étape 4)
|
|
90
|
-
|
|
90
|
+
state_recovery_wait && return 0
|
|
91
91
|
if [ "$(ports_auto_actif)" = off ]; then
|
|
92
92
|
# Jamais de désinstallation sur un état non confirmé (#417, étape 4)
|
|
93
|
-
|
|
93
|
+
state_recovery_pending || nettoyer_auto_tout
|
|
94
94
|
return 0
|
|
95
95
|
fi
|
|
96
96
|
if ! reseau_ip; then echo "devzone : ports-auto : conteneur devzone introuvable" >&2; return 1; fi
|
|
@@ -141,7 +141,7 @@ ports_auto_tour() {
|
|
|
141
141
|
if grep -q "^$port " "$PENDING" 2>/dev/null; then
|
|
142
142
|
ancien="$(grep "^$port " "$PENDING" | head -1 | cut -d' ' -f2)"
|
|
143
143
|
# Rien ne se retire sur un état restauré non confirmé (#417)
|
|
144
|
-
if
|
|
144
|
+
if state_recovery_pending; then continue; fi
|
|
145
145
|
if [ -n "$ancien" ] && [ "$(( now - ancien ))" -ge "$delay" ]; then
|
|
146
146
|
fermer_auto "$port"
|
|
147
147
|
grep -v "^$port " "$PENDING" >"$PENDING.tmp" 2>/dev/null || true; mv "$PENDING.tmp" "$PENDING" 2>/dev/null || true
|
|
@@ -168,7 +168,7 @@ ports_auto_boucle() {
|
|
|
168
168
|
trap 'nettoyer_auto_tout; rm -rf "$VERROU"' EXIT INT TERM
|
|
169
169
|
while true; do
|
|
170
170
|
# État restauré ou reconstruit : rien pendant 60 s (#417, étape 4)
|
|
171
|
-
if
|
|
171
|
+
if state_recovery_wait; then
|
|
172
172
|
verrou_rafraichir
|
|
173
173
|
sleep "${DEVZONE_PORTS_AUTO_PAS:-2}"
|
|
174
174
|
continue
|
|
@@ -178,7 +178,7 @@ ports_auto_boucle() {
|
|
|
178
178
|
verrou_rafraichir
|
|
179
179
|
if [ "$(ports_auto_actif)" = off ]; then
|
|
180
180
|
# Jamais de désinstallation sur un état non confirmé (#417)
|
|
181
|
-
|
|
181
|
+
state_recovery_pending || nettoyer_auto_tout
|
|
182
182
|
break
|
|
183
183
|
fi
|
|
184
184
|
ports_auto_tour || true
|
package/.devcontainer/ports.sh
CHANGED
|
@@ -43,7 +43,7 @@ trier_ports() {
|
|
|
43
43
|
|
|
44
44
|
# Écrit la ligne ports= de l'état (#417 : jamais de mv hors de etat.sh)
|
|
45
45
|
ecrire_ports() {
|
|
46
|
-
|
|
46
|
+
state_write ports "${1:-}" || { echo "devzone : port : état non enregistré : $ETAT" >&2; exit 1; }
|
|
47
47
|
}
|
|
48
48
|
|
|
49
49
|
ajouter_port() {
|
|
@@ -37,7 +37,7 @@ refuse() { echo "devzone : postgres : $*" >&2; exit 2; }
|
|
|
37
37
|
|
|
38
38
|
# Vue regroupée des identifiants : un échec n'empêche jamais l'opération
|
|
39
39
|
regenerer_identifiants() {
|
|
40
|
-
|
|
40
|
+
password_regenerate ||
|
|
41
41
|
echo "devzone : postgres : identifiants regroupés non mis à jour (devzone passwords)" >&2
|
|
42
42
|
}
|
|
43
43
|
|
|
@@ -73,9 +73,9 @@ cleanup() {
|
|
|
73
73
|
rm -f "$kubeconfig"
|
|
74
74
|
"$DEVZONE_CMD" "$service" relay-stop >/dev/null 2>&1 || true
|
|
75
75
|
if [ -n "$cluster_before" ]; then
|
|
76
|
-
|
|
76
|
+
state_write cluster "$cluster_before" || true
|
|
77
77
|
else
|
|
78
|
-
|
|
78
|
+
state_remove cluster || true
|
|
79
79
|
fi
|
|
80
80
|
}
|
|
81
81
|
trap cleanup EXIT
|
|
@@ -109,7 +109,7 @@ unset token ca_data
|
|
|
109
109
|
export KUBECONFIG="$kubeconfig"
|
|
110
110
|
export DEVZONE_KUBE_CONFIG="$kubeconfig"
|
|
111
111
|
export DEVZONE_SERVICES_ADMIN=1
|
|
112
|
-
|
|
112
|
+
state_write cluster "$ADMIN_CONTEXT" || refuse "cannot write the state: $ETAT"
|
|
113
113
|
echo "devzone services: $action $service in the cluster of the pod (temporary administrator)"
|
|
114
114
|
case "$action" in
|
|
115
115
|
# The seed is a module command: devzone gitlab seed (#538)
|
package/README.md
CHANGED
|
@@ -203,7 +203,7 @@ La liste vit dans `.devzone.paquets` à la racine du dossier devzone, hors du d
|
|
|
203
203
|
|
|
204
204
|
Dans le mode Kubernetes (poste créé alors que le cluster répondait, ou après `devzone workspace migrate`), le même tableau s'applique au pod `devzone-workspace-0` : `make up`, `make shell` et `make stop` le pilotent, et `make rebuild` est refusé, car rien n'est à reconstruire sur la machine. `devzone workspace revert` rend le poste Docker (déprécié : un avertissement s'affiche, retrait prévu). Les services GitLab, PostgreSQL et Argo CD s'installent depuis le poste : `devzone workspace services enable postgres` (voir [la référence](manage/docs/reference.md#services-de-devzone-dans-le-workspace-kubernetes)). Tu peux aussi y développer : `devzone workspace clone <url>` fait un clone de travail dans le pod, `devzone ticket <n>` y crée le worktree d'un ticket et `devzone agent` y lance opencode sans copie ([développer dans le pod](manage/docs/reference.md#développer-devzone-et-repowarden-dans-le-pod)). Argo CD y est installé d'office et tient les déploiements : interface sur https://localhost:8443 (mot de passe `admin` dans `.password`), dépôt GitOps `<login>/devzone-argocd` créé sur ton GitHub, projets déclarés dans `.argocd.conf` (`devzone workspace argocd app add <dépôt>`) ; voir [Argo CD dans le workspace Kubernetes](manage/docs/reference.md#argo-cd-dans-le-workspace-kubernetes).
|
|
205
205
|
|
|
206
|
-
Dans le conteneur, `devzone --help` liste toutes les commandes. Extrait :
|
|
206
|
+
Dans le conteneur, `devzone --version` affiche la version de l'image du workspace, et `devzone --help` liste toutes les commandes. Extrait :
|
|
207
207
|
|
|
208
208
|
```text
|
|
209
209
|
devzone enable <module> enable and apply at once
|
|
@@ -264,7 +264,7 @@ La commande `devzone` s'écrit en anglais, sous-commandes et options comprises (
|
|
|
264
264
|
Les comptes créés par devzone sont regroupés dans `.password`, à la racine de devzone (à côté de `.devzone.modules`). Une ligne par compte, colonnes séparées par des tabulations :
|
|
265
265
|
|
|
266
266
|
```text
|
|
267
|
-
# service
|
|
267
|
+
# service address user password
|
|
268
268
|
gitlab http://gitlab.localhost:8929 root …
|
|
269
269
|
postgres 127.0.0.1:5432 postgres …
|
|
270
270
|
postgres:monprojet 127.0.0.1:5432/monprojet monprojet …
|
|
@@ -159,6 +159,9 @@ spec:
|
|
|
159
159
|
# Marker of the Kubernetes workspace: devzone agent runs opencode here (#431)
|
|
160
160
|
- name: DEVZONE_WORKSPACE
|
|
161
161
|
value: kubernetes
|
|
162
|
+
# Version of the workspace image, shown by devzone --version (#707)
|
|
163
|
+
- name: DEVZONE_VERSION
|
|
164
|
+
value: {{ .Values.image.tag | default .Chart.AppVersion | quote }}
|
|
162
165
|
# Root of the devzone projects in the Kubernetes workspace (#503)
|
|
163
166
|
- name: DEVZONE_RACINE
|
|
164
167
|
value: /workspaces/projets
|