devzone 0.37.0 → 0.38.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/.dockerignore +1 -1
- package/.devcontainer/argocd/argocd.sh +6 -7
- package/.devcontainer/argocd/catalogue-argocd.sh +114 -0
- package/.devcontainer/argocd/services.sh +138 -0
- package/.devcontainer/catalogue/app.sh +58 -17
- package/.devcontainer/catalogue/mysql/installer.sh +31 -0
- package/.devcontainer/catalogue/mysql/mysql.sh +12 -0
- package/.devcontainer/devzone +1 -1
- package/.devcontainer/password.sh +8 -0
- package/README.md +1 -1
- package/charts/devzone-argocd/Chart.lock +6 -0
- package/charts/devzone-argocd/Chart.yaml +13 -0
- package/charts/devzone-argocd/values.yaml +28 -0
- package/charts/devzone-mysql/Chart.yaml +6 -0
- package/charts/devzone-mysql/templates/service.yaml +15 -0
- package/charts/devzone-mysql/templates/statefulset.yaml +55 -0
- package/charts/devzone-mysql/values.yaml +19 -0
- package/manage/devzone +2 -1
- package/manage/scripts/argocd-services-svc.sh +110 -0
- package/manage/scripts/argocd-services.sh +21 -85
- package/manage/scripts/argocd-workspace.sh +8 -6
- package/manage/scripts/ci-dns.sh +10 -10
- package/manage/scripts/desinstaller.sh +137 -135
- package/manage/scripts/docker.sh +26 -22
- package/manage/scripts/lancer.sh +103 -103
- package/manage/scripts/migrer-retour.sh +37 -34
- package/manage/scripts/migrer.sh +154 -138
- package/manage/scripts/ports-workspace.sh +87 -82
- package/manage/scripts/poste.sh +48 -49
- package/manage/scripts/services-workspace.sh +15 -10
- package/manage/scripts/versions.sh +88 -88
- package/manage/scripts/workspace-aliases.sh +47 -0
- package/manage/scripts/workspace-wait.sh +26 -23
- package/manage/workspace.sh +124 -111
- package/package.json +1 -1
- package/.devcontainer/argocd/values.yaml +0 -25
package/manage/scripts/lancer.sh
CHANGED
|
@@ -1,44 +1,44 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
# bash manage/scripts/lancer.sh up [
|
|
4
|
-
# bash manage/scripts/lancer.sh rebuild [
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
#
|
|
8
|
-
#
|
|
9
|
-
#
|
|
10
|
-
#
|
|
11
|
-
# Portable : bash 3.2 (macOS) et Linux.
|
|
2
|
+
# Starts the container on the host without ever staying silent:
|
|
3
|
+
# bash manage/scripts/lancer.sh up [folder] (make up)
|
|
4
|
+
# bash manage/scripts/lancer.sh rebuild [folder] (make rebuild: rebuild from scratch)
|
|
5
|
+
# Full devcontainer CLI output goes to <folder>/.devzone.log; the terminal shows
|
|
6
|
+
# key steps, a heartbeat at least every DEVZONE_SIGNE_DE_VIE seconds (30), and a
|
|
7
|
+
# question asked inside the container (last log line left unanswered for
|
|
8
|
+
# DEVZONE_ATTENTE_QUESTION seconds, 20) is shown and startup is stopped: nobody
|
|
9
|
+
# can answer it (the CLI runs without input), waiting would hang forever.
|
|
10
|
+
# Portable: bash 3.2 (macOS) and Linux.
|
|
12
11
|
set -uo pipefail
|
|
13
12
|
|
|
14
13
|
mode="${1:-}"
|
|
15
|
-
|
|
14
|
+
FOLDER="${2:-$PWD}"
|
|
16
15
|
case "$mode" in
|
|
17
|
-
up) options=()
|
|
18
|
-
rebuild) options=(--remove-existing-container)
|
|
16
|
+
up) options=() done_msg="devzone started" ;;
|
|
17
|
+
rebuild) options=(--remove-existing-container) done_msg="devzone rebuilt" ;;
|
|
19
18
|
*)
|
|
20
|
-
echo "usage
|
|
19
|
+
echo "usage: bash manage/scripts/lancer.sh up|rebuild [folder]" >&2
|
|
21
20
|
exit 2
|
|
22
21
|
;;
|
|
23
22
|
esac
|
|
24
23
|
|
|
25
|
-
#
|
|
26
|
-
#
|
|
27
|
-
|
|
24
|
+
# Host Docker socket (#432): docker-hote line in instance state, written by devzone
|
|
25
|
+
# inside the container. Missing or on: historical behavior.
|
|
26
|
+
host_off() {
|
|
28
27
|
local v
|
|
29
|
-
v="$(grep -E '^docker-hote=' "$
|
|
28
|
+
v="$(grep -E '^docker-hote=' "$FOLDER/.devzone.modules" 2>/dev/null | tail -1 | cut -d= -f2 || true)"
|
|
30
29
|
[ "$v" = off ]
|
|
31
30
|
}
|
|
32
31
|
|
|
33
|
-
#
|
|
34
|
-
#
|
|
35
|
-
#
|
|
36
|
-
#
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
32
|
+
# Copy of devcontainer.json without the docker-outside-of-docker feature, for a
|
|
33
|
+
# container without the host socket. The file lives one level deeper: build
|
|
34
|
+
# paths go up one level (../). Written at each start, in a git-ignored folder;
|
|
35
|
+
# comments from the original JSON are kept.
|
|
36
|
+
# shellcheck disable=SC2034
|
|
37
|
+
generate_config_without_host_docker() {
|
|
38
|
+
local folder="$FOLDER/.devcontainer/without-host-docker" context=no
|
|
39
|
+
grep -q '"context"' "$FOLDER/.devcontainer/devcontainer.json" && context=yes
|
|
40
|
+
mkdir -p "$folder"
|
|
41
|
+
awk -v context="$context" '
|
|
42
42
|
/ghcr\.io\/devcontainers\/features\/docker-outside-of-docker/ { next }
|
|
43
43
|
/"build"[[:space:]]*:[[:space:]]*\{[[:space:]]*"dockerfile"[[:space:]]*:[[:space:]]*"Dockerfile"[[:space:]]*\}/ {
|
|
44
44
|
sub(/\{[[:space:]]*"dockerfile"[[:space:]]*:[[:space:]]*"Dockerfile"[[:space:]]*\}/,
|
|
@@ -46,7 +46,7 @@ generer_config_sans_docker_hote() {
|
|
|
46
46
|
print
|
|
47
47
|
next
|
|
48
48
|
}
|
|
49
|
-
|
|
49
|
+
context == "no" && /"build"[[:space:]]*:[[:space:]]*\{[[:space:]]*$/ {
|
|
50
50
|
print
|
|
51
51
|
print " \"context\": \"..\","
|
|
52
52
|
next
|
|
@@ -55,124 +55,124 @@ generer_config_sans_docker_hote() {
|
|
|
55
55
|
sub(/"dockerfile"[[:space:]]*:[[:space:]]*"[^"]*"/, "\"dockerfile\": \"../Dockerfile\"")
|
|
56
56
|
}
|
|
57
57
|
{ print }
|
|
58
|
-
' "$
|
|
58
|
+
' "$FOLDER/.devcontainer/devcontainer.json" >"$folder/devcontainer.json"
|
|
59
59
|
}
|
|
60
60
|
|
|
61
|
-
if
|
|
62
|
-
|
|
63
|
-
options+=(--config "$
|
|
61
|
+
if host_off; then
|
|
62
|
+
generate_config_without_host_docker
|
|
63
|
+
options+=(--config "$FOLDER/.devcontainer/without-host-docker/devcontainer.json")
|
|
64
64
|
fi
|
|
65
|
-
LOG="$
|
|
66
|
-
|
|
67
|
-
|
|
65
|
+
LOG="$FOLDER/.devzone.log"
|
|
66
|
+
HEARTBEAT="${DEVZONE_SIGNE_DE_VIE:-30}"
|
|
67
|
+
QUESTION_WAIT="${DEVZONE_ATTENTE_QUESTION:-20}"
|
|
68
68
|
ESC="$(printf '\033')"
|
|
69
69
|
|
|
70
|
-
#
|
|
71
|
-
|
|
72
|
-
#
|
|
73
|
-
|
|
70
|
+
# Readable log line: without color codes or carriage returns
|
|
71
|
+
clean_line() { sed "s/${ESC}\[[0-9;?]*[A-Za-z]//g" | tr -d '\r'; }
|
|
72
|
+
# Last non-empty log line, shortened
|
|
73
|
+
last_line() { tail -c 2000 "$LOG" | clean_line | grep -v '^[[:space:]]*$' | tail -1 | cut -c1-110; }
|
|
74
74
|
|
|
75
|
-
#
|
|
76
|
-
#
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
local
|
|
80
|
-
#
|
|
75
|
+
# Pending question: last unfinished line (no newline, like a prompt) ending with
|
|
76
|
+
# [o/N], [y/N], ? or a password prompt
|
|
77
|
+
pattern='(\[[^]]*/[^]]*\]|\?|[Pp]assword[^:]*:|[Mm]ot de passe[^:]*:)[[:space:]]*$'
|
|
78
|
+
pending_question() {
|
|
79
|
+
local line
|
|
80
|
+
# Last byte: empty after $( ) if it is a newline
|
|
81
81
|
[ -n "$(tail -c 1 "$LOG")" ] || return 1
|
|
82
|
-
|
|
83
|
-
[[ "$
|
|
84
|
-
printf '%s\n' "$
|
|
82
|
+
line="$(tail -c 600 "$LOG" | clean_line | tail -1)"
|
|
83
|
+
[[ "$line" =~ $pattern ]] || return 1
|
|
84
|
+
printf '%s\n' "$line" | cut -c1-200
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
#
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
local total
|
|
87
|
+
# Key steps, each shown once; devzone state copied as-is
|
|
88
|
+
seen=" "
|
|
89
|
+
read_lines=0
|
|
90
|
+
show_steps() {
|
|
91
|
+
local total line
|
|
92
92
|
total="$(wc -l <"$LOG" | tr -d ' ')"
|
|
93
|
-
[ "$total" -gt "$
|
|
94
|
-
while IFS= read -r
|
|
95
|
-
case "$
|
|
96
|
-
*"Start: Run: docker buildx build"* | *"Start: Run: docker build"*)
|
|
97
|
-
*"Start: Run: docker run"*)
|
|
98
|
-
*"Running the postCreateCommand"*)
|
|
99
|
-
*"Running the postStartCommand"*)
|
|
100
|
-
"devzone
|
|
101
|
-
echo " $
|
|
102
|
-
|
|
93
|
+
[ "$total" -gt "$read_lines" ] || return 0
|
|
94
|
+
while IFS= read -r line; do
|
|
95
|
+
case "$line" in
|
|
96
|
+
*"Start: Run: docker buildx build"* | *"Start: Run: docker build"*) announce image "Building image (several minutes the first time)" ;;
|
|
97
|
+
*"Start: Run: docker run"*) announce container "Creating container" ;;
|
|
98
|
+
*"Running the postCreateCommand"*) announce postcreate "Installing in container (repowarden, modules)" ;;
|
|
99
|
+
*"Running the postStartCommand"*) announce poststart "Starting (git identity, clusters, state)" ;;
|
|
100
|
+
"devzone ready"* | "devzone started"* | "devzone rebuilt"* | "devzone : "* | " ✔ "* | " ✖ "* | " ○ "* | " ⚠ "* | " "[!\ ]* | "git-identite : "* | "kube-config : "* | "metrics-server : "*)
|
|
101
|
+
echo " $line"
|
|
102
|
+
last_announce="$(date +%s)"
|
|
103
103
|
;;
|
|
104
104
|
esac
|
|
105
|
-
done < <(sed -n "$((
|
|
106
|
-
|
|
105
|
+
done < <(sed -n "$((read_lines + 1)),${total}p" "$LOG" | clean_line)
|
|
106
|
+
read_lines="$total"
|
|
107
107
|
}
|
|
108
|
-
|
|
109
|
-
case "$
|
|
110
|
-
|
|
108
|
+
announce() {
|
|
109
|
+
case "$seen" in *" $1 "*) return 0 ;; esac
|
|
110
|
+
seen="$seen$1 "
|
|
111
111
|
echo "▶ $2"
|
|
112
|
-
|
|
112
|
+
last_announce="$(date +%s)"
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
|
|
115
|
+
stop_launch() {
|
|
116
116
|
[ -n "${pid:-}" ] || return 0
|
|
117
117
|
pkill -TERM -P "$pid" 2>/dev/null || true
|
|
118
118
|
kill -TERM "$pid" 2>/dev/null || true
|
|
119
119
|
wait "$pid" 2>/dev/null || true
|
|
120
120
|
pid=""
|
|
121
121
|
}
|
|
122
|
-
trap '
|
|
122
|
+
trap 'stop_launch; echo; echo "interrupted - log: .devzone.log"; exit 130' INT TERM
|
|
123
123
|
|
|
124
|
-
# Docker
|
|
124
|
+
# Docker first: without it the CLI would only show a raw JSON error
|
|
125
125
|
# shellcheck source=SCRIPTDIR/docker.sh
|
|
126
126
|
. "$(dirname "${BASH_SOURCE[0]}")/docker.sh"
|
|
127
|
-
|
|
127
|
+
docker_ready "${DEVZONE_COMMANDE:-make $mode}" || exit 1
|
|
128
128
|
|
|
129
129
|
: >"$LOG"
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
echo "▶
|
|
133
|
-
#
|
|
134
|
-
#
|
|
135
|
-
npx -y @devcontainers/cli up --workspace-folder "$
|
|
130
|
+
start="$(date +%s)"
|
|
131
|
+
last_announce="$start"
|
|
132
|
+
echo "▶ Starting devzone (full log: .devzone.log)"
|
|
133
|
+
# Empty input: the CLI forwards nothing; a question asked inside the container
|
|
134
|
+
# would stay unanswered, hence the detection below
|
|
135
|
+
npx -y @devcontainers/cli up --workspace-folder "$FOLDER" ${options[@]+"${options[@]}"} </dev/null >"$LOG" 2>&1 &
|
|
136
136
|
pid=$!
|
|
137
137
|
|
|
138
|
-
|
|
139
|
-
|
|
138
|
+
size=0
|
|
139
|
+
quiet=0
|
|
140
140
|
while kill -0 "$pid" 2>/dev/null; do
|
|
141
141
|
sleep 1
|
|
142
142
|
t="$(wc -c <"$LOG" | tr -d ' ')"
|
|
143
|
-
if [ "$t" != "$
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
143
|
+
if [ "$t" != "$size" ]; then
|
|
144
|
+
size="$t"
|
|
145
|
+
quiet=0
|
|
146
|
+
show_steps
|
|
147
147
|
else
|
|
148
|
-
|
|
148
|
+
quiet=$((quiet + 1))
|
|
149
149
|
fi
|
|
150
|
-
if [ "$
|
|
151
|
-
|
|
152
|
-
echo "✖
|
|
150
|
+
if [ "$quiet" -ge "$QUESTION_WAIT" ] && q="$(pending_question)"; then
|
|
151
|
+
stop_launch
|
|
152
|
+
echo "✖ A container step asks a question and waits for an answer (log idle for $quiet s):" >&2
|
|
153
153
|
echo " $q" >&2
|
|
154
|
-
echo "
|
|
155
|
-
echo "
|
|
156
|
-
echo "
|
|
154
|
+
echo " Nobody can answer it here: startup stopped instead of waiting forever." >&2
|
|
155
|
+
echo " Full log: .devzone.log; report it: https://github.com/SimBienvenueHoulBoumi/devzone/issues" >&2
|
|
156
|
+
echo " The container may be incomplete: make rebuild to start from scratch." >&2
|
|
157
157
|
exit 1
|
|
158
158
|
fi
|
|
159
|
-
|
|
160
|
-
if [ $((
|
|
161
|
-
|
|
162
|
-
info="
|
|
163
|
-
[ "$
|
|
164
|
-
echo " … $info
|
|
165
|
-
|
|
159
|
+
now="$(date +%s)"
|
|
160
|
+
if [ $((now - last_announce)) -ge "$HEARTBEAT" ]; then
|
|
161
|
+
elapsed=$((now - start))
|
|
162
|
+
info="running for $((elapsed / 60)) min $((elapsed % 60)) s"
|
|
163
|
+
[ "$quiet" -lt "$HEARTBEAT" ] || info="$info, no new line for $quiet s"
|
|
164
|
+
echo " … $info: $(last_line)"
|
|
165
|
+
last_announce="$now"
|
|
166
166
|
fi
|
|
167
167
|
done
|
|
168
168
|
wait "$pid"
|
|
169
169
|
code=$?
|
|
170
170
|
pid=""
|
|
171
|
-
|
|
171
|
+
show_steps
|
|
172
172
|
if [ "$code" -eq 0 ]; then
|
|
173
|
-
echo "$
|
|
173
|
+
echo "$done_msg"
|
|
174
174
|
else
|
|
175
|
-
tail -15 "$LOG" |
|
|
176
|
-
echo "
|
|
175
|
+
tail -15 "$LOG" | clean_line
|
|
176
|
+
echo "failed - full log: .devzone.log"
|
|
177
177
|
exit 1
|
|
178
178
|
fi
|
|
@@ -1,54 +1,57 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
#
|
|
3
|
-
#
|
|
4
|
-
#
|
|
5
|
-
#
|
|
2
|
+
# Rollback from Kubernetes workspace to Docker workstation (#403): devzone workspace
|
|
3
|
+
# revert [--bring-back]. Sourced by manage/workspace.sh after migrer.sh (uses
|
|
4
|
+
# copy_from, record_workspace, fail and kc). With --bring-back, the workstation
|
|
5
|
+
# version of a project is moved to .devzone.sauvegarde/<date>/ before being replaced.
|
|
6
6
|
|
|
7
|
-
#
|
|
8
|
-
# devzone
|
|
9
|
-
|
|
10
|
-
local base
|
|
7
|
+
# Backup folder for this run (relative to devzone), same convention as
|
|
8
|
+
# devzone update: .devzone.sauvegarde/<YYYYMMDD-HHMMSS>, -n suffix if taken.
|
|
9
|
+
backup_folder() {
|
|
10
|
+
local base folder n=1
|
|
11
11
|
base=".devzone.sauvegarde/$(date +%Y%m%d-%H%M%S)"
|
|
12
|
-
|
|
13
|
-
while [ -e "$
|
|
12
|
+
folder="$base"
|
|
13
|
+
while [ -e "$folder" ]; do
|
|
14
14
|
n=$((n + 1))
|
|
15
|
-
|
|
15
|
+
folder="$base-$n"
|
|
16
16
|
done
|
|
17
|
-
printf '%s' "$
|
|
17
|
+
printf '%s' "$folder"
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
#
|
|
21
|
-
#
|
|
22
|
-
|
|
23
|
-
local p="$1"
|
|
20
|
+
# Brings project $1 back from the pod; its workstation version ($2: backup folder)
|
|
21
|
+
# is moved first. If the move fails, nothing is overwritten.
|
|
22
|
+
bring_back_project() {
|
|
23
|
+
local p="$1" backup="$2"
|
|
24
24
|
if [ -e "workspace/$p" ]; then
|
|
25
|
-
mkdir -p "$
|
|
26
|
-
|
|
25
|
+
if ! mkdir -p "$backup/workspace" || ! mv "workspace/$p" "$backup/workspace/$p"; then
|
|
26
|
+
fail "backup of workspace/$p failed: nothing was overwritten"
|
|
27
27
|
return 1
|
|
28
|
-
|
|
29
|
-
echo "
|
|
28
|
+
fi
|
|
29
|
+
echo "project $p: workstation version saved in $backup/"
|
|
30
30
|
fi
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
copy_from "$PWD/workspace/$p" || {
|
|
32
|
+
fail "bring-back of $p failed (workstation version: $backup/workspace/$p)"
|
|
33
33
|
return 1
|
|
34
34
|
}
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
# devzone workspace
|
|
38
|
-
|
|
39
|
-
local
|
|
40
|
-
|
|
41
|
-
if [ "$
|
|
42
|
-
echo "▶
|
|
43
|
-
|
|
37
|
+
# devzone workspace revert [--bring-back]: workspace=docker; --bring-back copies projects from the pod first.
|
|
38
|
+
revert_workspace() {
|
|
39
|
+
local bring_back p list backup
|
|
40
|
+
bring_back="$(read_flag --bring-back "revert [--bring-back]" "$@")" || return 1
|
|
41
|
+
if [ "$bring_back" = 1 ]; then
|
|
42
|
+
echo "▶ bring-back: projects from pod to ./workspace (workstation version is saved first)"
|
|
43
|
+
list="$(kc exec "$POD" -c workspace -- ls -1 "$PROJECTS_DIR")" || { fail "cannot read project list from pod"; return 1; }
|
|
44
44
|
mkdir -p workspace
|
|
45
|
-
|
|
45
|
+
backup="$(backup_folder)"
|
|
46
46
|
while IFS= read -r p; do
|
|
47
47
|
[ -n "$p" ] || continue
|
|
48
48
|
echo " … $p"
|
|
49
|
-
|
|
50
|
-
done <<<"$
|
|
49
|
+
bring_back_project "$p" "$backup" || return 1
|
|
50
|
+
done <<<"$list"
|
|
51
51
|
fi
|
|
52
|
-
|
|
53
|
-
echo "✔ workspace=docker
|
|
52
|
+
record_workspace docker || { fail "cannot write .devzone.modules"; return 1; }
|
|
53
|
+
echo "✔ workspace=docker: Docker workstation and its volumes are intact. Start it again: make shell"
|
|
54
54
|
}
|
|
55
|
+
|
|
56
|
+
# compatibility alias, removed with lot 4 (#509)
|
|
57
|
+
revenir() { revert_workspace "$@"; }
|