devzone 7.4.0 → 7.4.1
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/devzone +13 -17
- package/.devcontainer/devzone-modules.sh +1 -1
- package/.devcontainer/devzone-repair.sh +2 -2
- package/.devcontainer/devzone-services.sh +7 -7
- package/.devcontainer/devzone-status.sh +5 -5
- package/.devcontainer/help.sh +3 -1
- package/.devcontainer/versions.env +3 -0
- package/.devcontainer/workspace-init.sh +8 -9
- package/.gitattributes +8 -0
- package/bin/SHA256SUMS +6 -6
- package/bin/devzone-darwin-amd64 +0 -0
- package/bin/devzone-darwin-arm64 +0 -0
- package/bin/devzone-linux-amd64 +0 -0
- package/bin/devzone-linux-arm64 +0 -0
- package/bin/devzone-windows-amd64.exe +0 -0
- package/bin/devzone-windows-arm64.exe +0 -0
- package/charts/devzone-mysql/values.yaml +1 -1
- package/charts/devzone-postgres/values.yaml +1 -1
- package/manage/devzone +2 -2
- package/manage/scripts/uninstall.sh +1 -1
- package/manage/scripts/workspace/argocd-workspace.sh +2 -2
- package/package.json +1 -1
- package/.devcontainer/catalog/app.sh +0 -202
- package/.devcontainer/catalog/catalog-watcher.sh +0 -127
- package/.devcontainer/catalog.sh +0 -208
- package/.devcontainer/chart-direct.sh +0 -49
- package/.devcontainer/cluster.sh +0 -388
- package/.devcontainer/clusters.sh +0 -86
- package/.devcontainer/devzone-cluster.sh +0 -209
- package/.devcontainer/isolation.sh +0 -65
- package/.devcontainer/kube-account.sh +0 -107
- package/.devcontainer/kube-prompt.sh +0 -42
- package/.devcontainer/memory.sh +0 -113
- package/.devcontainer/metrics-server.sh +0 -100
- package/.devcontainer/packages.sh +0 -228
- package/.devcontainer/password.sh +0 -148
- package/.devcontainer/ports-json.sh +0 -31
- package/.devcontainer/ports.sh +0 -132
|
@@ -1,148 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Grouped credentials of the accounts created by devzone (#332).
|
|
3
|
-
# password.sh regenerate reads the module files, writes $ROOT/.password
|
|
4
|
-
# password.sh path 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
|
-
set -euo pipefail
|
|
8
|
-
|
|
9
|
-
PASSWORD_HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
10
|
-
PASSWORD_ROOT="${DEVZONE_ROOT:-$(dirname "$PASSWORD_HERE")}"
|
|
11
|
-
PASSWORD_TARGET="$PASSWORD_ROOT/.password"
|
|
12
|
-
|
|
13
|
-
# Regenerates $ROOT/.password from workspace/.gitlab, workspace/.postgres,
|
|
14
|
-
# workspace/.argocd, workspace/.mysql and the other workspace/.<app>/ folders.
|
|
15
|
-
# Silent on success; without any account, the file is removed.
|
|
16
|
-
password_regenerate() (
|
|
17
|
-
umask 077
|
|
18
|
-
local target="$PASSWORD_TARGET" root="$PASSWORD_ROOT"
|
|
19
|
-
local gl="$root/workspace/.gitlab" pg="$root/workspace/.postgres"
|
|
20
|
-
local ar="$root/workspace/.argocd"
|
|
21
|
-
local my="$root/workspace/.mysql"
|
|
22
|
-
local tab entries tmp file name service address user secret
|
|
23
|
-
tab="$(printf '\t')"
|
|
24
|
-
entries="$(mktemp "$root/.password.entries.XXXXXX")" || return 1
|
|
25
|
-
tmp=""
|
|
26
|
-
|
|
27
|
-
if [ -s "$gl/root-password" ]; then
|
|
28
|
-
secret="$(cat "$gl/root-password")"
|
|
29
|
-
if [ -n "$secret" ]; then
|
|
30
|
-
printf 'gitlab\t%s\troot\t%s\n' "http://gitlab.localhost:8929" "$secret" >>"$entries"
|
|
31
|
-
fi
|
|
32
|
-
fi
|
|
33
|
-
if [ -s "$gl/dev-password" ]; then
|
|
34
|
-
secret="$(cat "$gl/dev-password")"
|
|
35
|
-
if [ -n "$secret" ]; then
|
|
36
|
-
printf 'gitlab\t%s\tdev\t%s\n' "http://gitlab.localhost:8929" "$secret" >>"$entries"
|
|
37
|
-
fi
|
|
38
|
-
fi
|
|
39
|
-
if [ -s "$pg/admin-password" ]; then
|
|
40
|
-
secret="$(cat "$pg/admin-password")"
|
|
41
|
-
if [ -n "$secret" ]; then
|
|
42
|
-
printf 'postgres\t%s\tpostgres\t%s\n' "127.0.0.1:5432" "$secret" >>"$entries"
|
|
43
|
-
fi
|
|
44
|
-
fi
|
|
45
|
-
# Catalogue MySQL root (direct helm or Argo CD, #538): mirror of the workstation
|
|
46
|
-
if [ -s "$my/admin-password" ]; then
|
|
47
|
-
secret="$(cat "$my/admin-password")"
|
|
48
|
-
if [ -n "$secret" ]; then
|
|
49
|
-
printf 'mysql\t%s\troot\t%s\n' "127.0.0.1:3306" "$secret" >>"$entries"
|
|
50
|
-
fi
|
|
51
|
-
fi
|
|
52
|
-
if [ -s "$ar/admin.env" ]; then
|
|
53
|
-
user="$(sed -n 's/^ARGOCD_USER=//p' "$ar/admin.env" 2>/dev/null | tail -1 || true)"
|
|
54
|
-
secret="$(sed -n 's/^ARGOCD_PASSWORD=//p' "$ar/admin.env" 2>/dev/null | tail -1 || true)"
|
|
55
|
-
if [ -n "$user" ] && [ -n "$secret" ]; then
|
|
56
|
-
printf 'argocd\t%s\t%s\t%s\n' "https://127.0.0.1:8443" "$user" "$secret" >>"$entries"
|
|
57
|
-
fi
|
|
58
|
-
fi
|
|
59
|
-
for file in "$pg"/*.env; do
|
|
60
|
-
[ -f "$file" ] || continue
|
|
61
|
-
name="${file##*/}"
|
|
62
|
-
name="${name%.env}"
|
|
63
|
-
service="postgres:$name"
|
|
64
|
-
user="$(sed -n 's/^DB_USER=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
65
|
-
secret="$(sed -n 's/^DB_PASSWORD=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
66
|
-
address="$(sed -n 's/^DB_NAME=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
67
|
-
if [ -z "$user" ] || [ -z "$secret" ]; then
|
|
68
|
-
continue
|
|
69
|
-
fi
|
|
70
|
-
address="127.0.0.1:5432/${address:-$name}"
|
|
71
|
-
printf '%s\t%s\t%s\t%s\n' "$service" "$address" "$user" "$secret" >>"$entries"
|
|
72
|
-
done
|
|
73
|
-
# Each other catalogue application: workspace/.<app>/*.env, keys <APP>_HOST,
|
|
74
|
-
# <APP>_PORT, <APP>_USER, <APP>_PASSWORD (or MYSQL_* for mysql)
|
|
75
|
-
for dir in "$root"/workspace/.*/; do
|
|
76
|
-
[ -d "$dir" ] || continue
|
|
77
|
-
app="${dir%/}"
|
|
78
|
-
app="${app##*/}"
|
|
79
|
-
case "$app" in . | .. | .gitlab | .postgres | .argocd) continue ;; esac
|
|
80
|
-
app="${app#.}"
|
|
81
|
-
app_upper="$(printf '%s' "$app" | tr '[:lower:]' '[:upper:]')"
|
|
82
|
-
for file in "$dir"*.env; do
|
|
83
|
-
[ -f "$file" ] || continue
|
|
84
|
-
base="${file##*/}"
|
|
85
|
-
base="${base%.env}"
|
|
86
|
-
user="$(sed -n "s/^${app_upper}_USER=//p" "$file" 2>/dev/null | tail -1 || true)"
|
|
87
|
-
[ -z "$user" ] && user="$(sed -n 's/^DB_USER=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
88
|
-
[ -z "$user" ] && user="$(sed -n 's/^MYSQL_USER=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
89
|
-
secret="$(sed -n "s/^${app_upper}_PASSWORD=//p" "$file" 2>/dev/null | tail -1 || true)"
|
|
90
|
-
[ -z "$secret" ] && secret="$(sed -n 's/^DB_PASSWORD=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
91
|
-
[ -z "$secret" ] && secret="$(sed -n 's/^MYSQL_PASSWORD=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
92
|
-
[ -z "$user" ] || [ -z "$secret" ] && continue
|
|
93
|
-
host="$(sed -n "s/^${app_upper}_HOST=//p" "$file" 2>/dev/null | tail -1 || true)"
|
|
94
|
-
[ -z "$host" ] && host="$(sed -n 's/^DB_HOST=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
95
|
-
[ -z "$host" ] && host="$(sed -n 's/^MYSQL_HOST=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
96
|
-
[ -z "$host" ] && host=127.0.0.1
|
|
97
|
-
port="$(sed -n "s/^${app_upper}_PORT=//p" "$file" 2>/dev/null | tail -1 || true)"
|
|
98
|
-
[ -z "$port" ] && port="$(sed -n 's/^DB_PORT=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
99
|
-
[ -z "$port" ] && port="$(sed -n 's/^MYSQL_PORT=//p' "$file" 2>/dev/null | tail -1 || true)"
|
|
100
|
-
[ -z "$port" ] && port=3306
|
|
101
|
-
printf '%s\t%s\t%s\t%s\n' "$app:$base" "$host:$port" "$user" "$secret" >>"$entries"
|
|
102
|
-
done
|
|
103
|
-
done
|
|
104
|
-
|
|
105
|
-
if [ ! -s "$entries" ]; then
|
|
106
|
-
rm -f "$entries" "$target"
|
|
107
|
-
return 0
|
|
108
|
-
fi
|
|
109
|
-
|
|
110
|
-
tmp="$(mktemp "$root/.password.XXXXXX")" || {
|
|
111
|
-
rm -f "$entries"
|
|
112
|
-
return 1
|
|
113
|
-
}
|
|
114
|
-
{
|
|
115
|
-
printf '%s\n' \
|
|
116
|
-
'# devzone : identifiers of the accounts created by devzone. Plain-text secrets:' \
|
|
117
|
-
'# never commit, copy or paste them into a ticket. Regenerated by devzone.' \
|
|
118
|
-
"# service${tab}address${tab}user${tab}password"
|
|
119
|
-
LC_ALL=C sort -t "$tab" -k1,1 -k3,3 "$entries"
|
|
120
|
-
} >"$tmp" || {
|
|
121
|
-
rm -f "$entries" "$tmp"
|
|
122
|
-
return 1
|
|
123
|
-
}
|
|
124
|
-
chmod 600 "$tmp" || {
|
|
125
|
-
rm -f "$entries" "$tmp"
|
|
126
|
-
return 1
|
|
127
|
-
}
|
|
128
|
-
mv "$tmp" "$target" || {
|
|
129
|
-
rm -f "$entries" "$tmp"
|
|
130
|
-
return 1
|
|
131
|
-
}
|
|
132
|
-
chmod 600 "$target" || {
|
|
133
|
-
rm -f "$entries"
|
|
134
|
-
return 1
|
|
135
|
-
}
|
|
136
|
-
rm -f "$entries"
|
|
137
|
-
)
|
|
138
|
-
|
|
139
|
-
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
|
140
|
-
case "${1:-}" in
|
|
141
|
-
regenerate) password_regenerate ;;
|
|
142
|
-
path) printf '%s\n' "$PASSWORD_TARGET" ;;
|
|
143
|
-
*)
|
|
144
|
-
echo "devzone : password.sh : regenerate | path" >&2
|
|
145
|
-
exit 1
|
|
146
|
-
;;
|
|
147
|
-
esac
|
|
148
|
-
fi
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# JSON output of the port relays (#557): the array
|
|
3
|
-
# [{port,active,application,auto}] read by the tools (devzone status --json).
|
|
4
|
-
# The keys and the application values are a contract.
|
|
5
|
-
# Sourced by ports.sh, which holds the functions used here.
|
|
6
|
-
|
|
7
|
-
# JSON list of the relays of the state: jq only
|
|
8
|
-
list_json() {
|
|
9
|
-
local ports port active app json='[]'
|
|
10
|
-
ports="$(sort_ports "$(read_ports)")"
|
|
11
|
-
if [ -z "$ports" ]; then
|
|
12
|
-
printf '[]\n'
|
|
13
|
-
return 0
|
|
14
|
-
fi
|
|
15
|
-
# shellcheck disable=SC2046 # list of ports separated by commas
|
|
16
|
-
for port in $(printf '%s' "$ports" | tr ',' ' '); do
|
|
17
|
-
if relay_active "$port"; then
|
|
18
|
-
active=true
|
|
19
|
-
else
|
|
20
|
-
active=false
|
|
21
|
-
fi
|
|
22
|
-
if app_responds "$port"; then
|
|
23
|
-
app="$JSON_APP_RESPONDS"
|
|
24
|
-
else
|
|
25
|
-
app="$JSON_APP_NONE"
|
|
26
|
-
fi
|
|
27
|
-
json="$(jq -c --argjson port "$port" --argjson active "$active" --arg app "$app" \
|
|
28
|
-
'. + [{port:$port,active:$active,application:$app,auto:false}]' <<<"$json")"
|
|
29
|
-
done
|
|
30
|
-
printf '%s\n' "$json"
|
|
31
|
-
}
|
package/.devcontainer/ports.sh
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env bash
|
|
2
|
-
# Port relays of the workstation (#290): applications reachable from
|
|
3
|
-
# 127.0.0.1 of the workstation, kept in the state of devzone.
|
|
4
|
-
# ports.sh list relays of the state: port, active, application
|
|
5
|
-
# ports.sh close <n> removes the relay and the port from the state
|
|
6
|
-
# ports.sh resume one-line summary for the devzone recap
|
|
7
|
-
# The state is the line "ports=8080,3000" of DEVZONE_STATE (sorted, no duplicate).
|
|
8
|
-
# ROOT: a single dirname from HERE (.devcontainer) = root of the devzone repository.
|
|
9
|
-
if [ "${BASH_SOURCE[0]}" = "$0" ]; then set -euo pipefail; fi
|
|
10
|
-
|
|
11
|
-
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
12
|
-
ROOT="${DEVZONE_ROOT:-$(dirname "$HERE")}"
|
|
13
|
-
ETAT="${DEVZONE_STATE:-$ROOT/.devzone.modules}"
|
|
14
|
-
INSTANCE="${DEVZONE_INSTANCE:-devzone}"
|
|
15
|
-
|
|
16
|
-
# Safe state write (#417): lock, temporary file in the state folder, backup copy
|
|
17
|
-
|
|
18
|
-
refuse() { echo "devzone : port : $*" >&2; exit 1; }
|
|
19
|
-
|
|
20
|
-
# Application labels: the list shows them in English. The JSON output keeps its
|
|
21
|
-
# French values (read by the tools, #557): a contract, UTF-8 written as byte escapes.
|
|
22
|
-
APP_RESPONDS="application responds"
|
|
23
|
-
APP_NONE="no application"
|
|
24
|
-
# shellcheck disable=SC2034 # read by ports-json.sh (sourced)
|
|
25
|
-
JSON_APP_RESPONDS=$'application r\303\251pond'
|
|
26
|
-
# shellcheck disable=SC2034 # read by ports-json.sh (sourced)
|
|
27
|
-
JSON_APP_NONE="aucune application"
|
|
28
|
-
|
|
29
|
-
relay_name() { echo "devzone-$INSTANCE-port-$1"; }
|
|
30
|
-
|
|
31
|
-
port_valid() { case "${1:-}" in '' | *[!0-9]*) return 1 ;; esac; [ "$1" -ge 1 ] 2>/dev/null && [ "$1" -le 65535 ] 2>/dev/null; }
|
|
32
|
-
|
|
33
|
-
validate_port() { port_valid "${1:-}" || refuse "invalid port : ${1:-(none)} (1-65535)"; }
|
|
34
|
-
|
|
35
|
-
read_ports() { grep -E '^ports=' "$ETAT" 2>/dev/null | tail -1 | cut -d= -f2- || true; }
|
|
36
|
-
|
|
37
|
-
sort_ports() {
|
|
38
|
-
printf '%s\n' "${1:-}" | tr ',' '\n' | awk 'NF && $0 ~ /^[0-9]+$/ { print }' | sort -n -u | paste -sd, -
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
# Writes the ports= line of the state (#417: never mv outside Go state command)
|
|
42
|
-
write_ports() {
|
|
43
|
-
DEVZONE_STATE="$ETAT" bash "$HERE/devzone" state write ports "${1:-}" || { echo "devzone : port : state not saved : $ETAT" >&2; exit 1; }
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
add_port() {
|
|
47
|
-
local port="$1"
|
|
48
|
-
write_ports "$(sort_ports "$(read_ports),$port")"
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
remove_port() {
|
|
52
|
-
local port="$1" rest="" p
|
|
53
|
-
# shellcheck disable=SC2046 # list of ports separated by commas
|
|
54
|
-
for p in $(printf '%s' "$(read_ports)" | tr ',' ' '); do
|
|
55
|
-
[ "$p" = "$port" ] || rest="$rest${rest:+,}$p"
|
|
56
|
-
done
|
|
57
|
-
write_ports "$(sort_ports "$rest")"
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
relay_active() {
|
|
61
|
-
local name
|
|
62
|
-
name="$(relay_name "$1")"
|
|
63
|
-
command -v docker >/dev/null 2>&1 || return 1
|
|
64
|
-
[ -n "$(docker ps --filter "name=^$name$" --format '{{.Names}}' 2>/dev/null |
|
|
65
|
-
grep -Fx "$name" || true)" ]
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
close_port() {
|
|
69
|
-
local port="${1:-}"
|
|
70
|
-
validate_port "$port"
|
|
71
|
-
docker rm -f "$(relay_name "$port")" >/dev/null 2>&1 || true
|
|
72
|
-
remove_port "$port"
|
|
73
|
-
echo "✔ relay closed: $port"
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
app_responds() { curl -s -o /dev/null --max-time 2 "http://127.0.0.1:$1" >/dev/null 2>&1; }
|
|
77
|
-
|
|
78
|
-
list_ports() {
|
|
79
|
-
local ports port mark app
|
|
80
|
-
ports="$(sort_ports "$(read_ports)")"
|
|
81
|
-
if [ -z "$ports" ]; then
|
|
82
|
-
echo "no relay"
|
|
83
|
-
return 0
|
|
84
|
-
fi
|
|
85
|
-
# shellcheck disable=SC2046 # list of ports separated by commas
|
|
86
|
-
for port in $(printf '%s' "$ports" | tr ',' ' '); do
|
|
87
|
-
if relay_active "$port"; then
|
|
88
|
-
mark="● active"
|
|
89
|
-
else
|
|
90
|
-
mark="○ stopped"
|
|
91
|
-
fi
|
|
92
|
-
if app_responds "$port"; then
|
|
93
|
-
app="$APP_RESPONDS"
|
|
94
|
-
else
|
|
95
|
-
app="$APP_NONE"
|
|
96
|
-
fi
|
|
97
|
-
printf ' %-5s %s %s\n' "$port" "$mark" "$app"
|
|
98
|
-
done
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
summary() {
|
|
102
|
-
local ports port output=""
|
|
103
|
-
ports="$(sort_ports "$(read_ports)")"
|
|
104
|
-
if [ -z "$ports" ]; then
|
|
105
|
-
echo "none"
|
|
106
|
-
return 0
|
|
107
|
-
fi
|
|
108
|
-
# shellcheck disable=SC2046 # list of ports separated by commas
|
|
109
|
-
for port in $(printf '%s' "$ports" | tr ',' ' '); do
|
|
110
|
-
if relay_active "$port"; then
|
|
111
|
-
output="$output${output:+, }$port ●"
|
|
112
|
-
else
|
|
113
|
-
output="$output${output:+, }$port ○"
|
|
114
|
-
fi
|
|
115
|
-
done
|
|
116
|
-
echo "$output"
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
# Machine-readable output of list: a JSON array [{port,active,application,auto}], jq only.
|
|
120
|
-
# shellcheck source=SCRIPTDIR/ports-json.sh
|
|
121
|
-
# shellcheck disable=SC1091
|
|
122
|
-
. "$HERE/ports-json.sh"
|
|
123
|
-
if [ "${BASH_SOURCE[0]}" = "$0" ]; then
|
|
124
|
-
case "${1:-}" in
|
|
125
|
-
'' | list)
|
|
126
|
-
if [ "${2:-}" = "--json" ]; then list_json; else list_ports; fi
|
|
127
|
-
;;
|
|
128
|
-
close | --close) close_port "${2:-}" ;;
|
|
129
|
-
resume) summary ;;
|
|
130
|
-
-h | --help) sed -n '2,8p' "$0" | sed 's/^# \{0,1\}//' ;;
|
|
131
|
-
esac
|
|
132
|
-
fi
|