devzone 2.0.0 → 4.0.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-errors.sh +6 -6
- package/.devcontainer/agent-pod-manifest.sh +4 -4
- package/.devcontainer/agent-session.sh +2 -2
- package/.devcontainer/agent-state-json.sh +2 -2
- package/.devcontainer/agent-workspace.sh +1 -1
- package/.devcontainer/agent.sh +7 -7
- package/.devcontainer/ai/host-models.sh +2 -2
- package/.devcontainer/ai/plugins/devzone-guard-v2.js +3 -3
- package/.devcontainer/ai/plugins/devzone-guard.js +3 -3
- package/.devcontainer/argocd/argocd.sh +90 -89
- package/.devcontainer/argocd/catalog-argocd.sh +2 -2
- package/.devcontainer/argocd/services-hook.sh +3 -3
- package/.devcontainer/argocd/services.sh +1 -1
- package/.devcontainer/catalog/app.sh +114 -116
- package/.devcontainer/catalog/catalog-watcher.sh +62 -62
- package/.devcontainer/catalog/mysql/app.conf +1 -1
- package/.devcontainer/catalog/mysql/install.sh +40 -40
- package/.devcontainer/catalog/mysql/mysql.sh +141 -141
- package/.devcontainer/catalog/mysql/volume.sh +39 -39
- package/.devcontainer/catalog.sh +112 -112
- package/.devcontainer/chart-direct.sh +1 -1
- package/.devcontainer/cluster.sh +216 -218
- package/.devcontainer/clusters.sh +41 -41
- package/.devcontainer/command-aliases.sh +17 -8
- package/.devcontainer/devzone +93 -1496
- package/.devcontainer/devzone-ai-guard.sh +76 -0
- package/.devcontainer/devzone-ai.sh +201 -0
- package/.devcontainer/devzone-cluster.sh +210 -0
- package/.devcontainer/devzone-modules.sh +126 -0
- package/.devcontainer/devzone-platform.sh +189 -0
- package/.devcontainer/devzone-repair.sh +94 -0
- package/.devcontainer/devzone-services.sh +241 -0
- package/.devcontainer/devzone-skill.sh +97 -0
- package/.devcontainer/devzone-status.sh +140 -0
- package/.devcontainer/devzone-version.sh +78 -0
- package/.devcontainer/git-identity.sh +28 -0
- package/.devcontainer/gitlab/chart.sh +2 -2
- package/.devcontainer/gitlab/gitlab.sh +81 -82
- package/.devcontainer/gitlab/installation.sh +109 -109
- package/.devcontainer/gitlab/secrets.sh +47 -47
- package/.devcontainer/gitlab/seed.sh +77 -77
- package/.devcontainer/gitlab/test-gitlab.sh +242 -243
- package/.devcontainer/help.sh +1 -1
- package/.devcontainer/isolation.sh +30 -30
- package/.devcontainer/kind-wrapper.sh +17 -17
- package/.devcontainer/kube-account.sh +112 -113
- package/.devcontainer/kube-config.sh +45 -46
- package/.devcontainer/{invite-kube.sh → kube-prompt.sh} +6 -6
- package/.devcontainer/kube-reachable.sh +40 -40
- package/.devcontainer/memory.sh +1 -1
- package/.devcontainer/metrics-server.sh +2 -2
- package/.devcontainer/opencode.jsonc +2 -2
- package/.devcontainer/packages.sh +136 -135
- package/.devcontainer/password.sh +1 -1
- package/.devcontainer/ports-auto.sh +152 -153
- package/.devcontainer/ports-json.sh +16 -15
- package/.devcontainer/ports.sh +126 -122
- package/.devcontainer/post-create.sh +52 -52
- package/.devcontainer/postgres/postgres.sh +174 -174
- package/.devcontainer/rename-legacy-files.sh +103 -0
- package/.devcontainer/services-admin.sh +3 -3
- package/.devcontainer/skills/devzone/SKILL.md +40 -41
- package/.devcontainer/startup.sh +48 -49
- package/.devcontainer/state-gitops.sh +1 -1
- package/.devcontainer/state-json.sh +36 -62
- package/.devcontainer/state.sh +2 -2
- package/.devcontainer/workspace-init.sh +16 -2
- package/Makefile +1 -1
- package/README.md +191 -195
- package/charts/devzone-workspace/templates/statefulset.yaml +1 -1
- package/manage/devzone +7 -11
- package/manage/scripts/argocd-workspace.sh +1 -1
- package/manage/scripts/{check-charts.sh → ci/check-charts.sh} +1 -1
- package/manage/scripts/{check-english.sh → ci/check-english.sh} +1 -1
- package/manage/scripts/{check-go-layout.sh → ci/check-go-layout.sh} +1 -1
- package/manage/scripts/{check-names.sh → ci/check-names.sh} +7 -6
- package/manage/scripts/{check-utf8-vars.sh → ci/check-utf8-vars.sh} +1 -1
- package/manage/scripts/{versions.sh → ci/versions.sh} +8 -8
- package/manage/scripts/create-cluster.sh +1 -1
- package/manage/scripts/create-mode.sh +11 -18
- package/manage/scripts/devzone-create.sh +7 -35
- package/manage/scripts/devzone-manifest.sh +1 -1
- package/manage/scripts/devzone-update.sh +12 -8
- package/manage/scripts/launch.sh +7 -48
- package/manage/scripts/ports-apps.sh +1 -1
- package/manage/scripts/ports-workspace.sh +7 -7
- package/manage/scripts/poste.sh +6 -7
- package/manage/scripts/uninstall.sh +8 -8
- package/manage/scripts/workspace-egress.sh +2 -2
- package/manage/scripts/workspace-update.sh +5 -2
- package/manage/scripts/workspace-wait.sh +2 -2
- package/manage/workspace.sh +2 -12
- package/package.json +1 -1
- package/.devcontainer/docker-relay.sh +0 -149
- package/.devcontainer/docker-without-host.sh +0 -12
- package/.devcontainer/git-identite.sh +0 -28
- package/manage/scripts/docker-workstation.sh +0 -73
- package/manage/scripts/migrate-revert.sh +0 -60
- package/manage/scripts/migrate.sh +0 -243
- /package/manage/scripts/{ci-dns.sh → ci/ci-dns.sh} +0 -0
|
@@ -35,10 +35,10 @@ cause_label() {
|
|
|
35
35
|
esac
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
# Duration of an exclusion in seconds: country 7 days (
|
|
38
|
+
# Duration of an exclusion in seconds: country 7 days (DEVZONE_AGENT_COUNTRY_EXCLUSION), the others 1 h.
|
|
39
39
|
exclusion_duration() {
|
|
40
40
|
case "$1" in
|
|
41
|
-
pays) echo "${
|
|
41
|
+
pays) echo "${DEVZONE_AGENT_COUNTRY_EXCLUSION:-604800}" ;;
|
|
42
42
|
*) echo 3600 ;;
|
|
43
43
|
esac
|
|
44
44
|
}
|
|
@@ -78,18 +78,18 @@ network_reachable() {
|
|
|
78
78
|
getent hosts opencode.ai >/dev/null 2>&1 && curl -sI --max-time 5 https://opencode.ai >/dev/null 2>&1
|
|
79
79
|
}
|
|
80
80
|
|
|
81
|
-
# Waits for the network to come back: a try every
|
|
82
|
-
#
|
|
81
|
+
# Waits for the network to come back: a try every DEVZONE_AGENT_NETWORK_STEP s, for
|
|
82
|
+
# DEVZONE_AGENT_NETWORK_MAX s at most. Returns 0 when it is back.
|
|
83
83
|
network_wait() {
|
|
84
84
|
local end
|
|
85
|
-
end=$(( $(date +%s) + ${
|
|
85
|
+
end=$(( $(date +%s) + ${DEVZONE_AGENT_NETWORK_MAX:-1800} ))
|
|
86
86
|
echo "=== network down, waiting" >>"$AGENT_JOURNAL"
|
|
87
87
|
while [ "$(date +%s)" -lt "$end" ]; do
|
|
88
88
|
if network_reachable; then
|
|
89
89
|
echo "=== network back" >>"$AGENT_JOURNAL"
|
|
90
90
|
return 0
|
|
91
91
|
fi
|
|
92
|
-
sleep "${
|
|
92
|
+
sleep "${DEVZONE_AGENT_NETWORK_STEP:-30}"
|
|
93
93
|
done
|
|
94
94
|
return 1
|
|
95
95
|
}
|
|
@@ -12,8 +12,8 @@ DEVZONE_AGENT_POD_CPU_LIMIT="${DEVZONE_AGENT_POD_CPU_LIMIT:-2}"
|
|
|
12
12
|
DEVZONE_AGENT_POD_MEM_LIMIT="${DEVZONE_AGENT_POD_MEM_LIMIT:-4Gi}"
|
|
13
13
|
DEVZONE_AGENT_POD_TIMEOUT="${DEVZONE_AGENT_POD_TIMEOUT:-$((DEVZONE_AGENT_POD_ACTIVE_DEADLINE_SECONDS + 120))}"
|
|
14
14
|
# Projects root, read by the launcher only (no trailing slash). The pod keeps
|
|
15
|
-
# /workspaces/projets in its own environment (
|
|
16
|
-
AGENT_POD_ROOT="${
|
|
15
|
+
# /workspaces/projets in its own environment (DEVZONE_ROOT in the manifest).
|
|
16
|
+
AGENT_POD_ROOT="${DEVZONE_ROOT:-/workspaces/projets}"
|
|
17
17
|
# Module state file on the workspace volume (subPath .devzone.modules, read-only in the pod).
|
|
18
18
|
# shellcheck disable=SC2034 # read by agent-pod.sh
|
|
19
19
|
AGENT_POD_MODULES_FILE="${DEVZONE_AGENT_POD_MODULES_FILE:-${AGENT_POD_ROOT}/.devzone.modules}"
|
|
@@ -193,7 +193,7 @@ agent_pod_build_manifest() {
|
|
|
193
193
|
printf '%s\n' " value: \"${ws_path}\""
|
|
194
194
|
printf '%s\n' " - name: DEVZONE_WORKSPACE"
|
|
195
195
|
printf '%s\n' " value: \"kubernetes\""
|
|
196
|
-
printf '%s\n' " - name:
|
|
196
|
+
printf '%s\n' " - name: DEVZONE_ROOT"
|
|
197
197
|
printf '%s\n' " value: \"/workspaces/projets\""; agent_pod_egress_manifest_lines "$egress_mode"
|
|
198
198
|
printf '%s\n' " resources:"
|
|
199
199
|
printf '%s\n' " limits:"
|
|
@@ -230,7 +230,7 @@ agent_pod_build_manifest() {
|
|
|
230
230
|
printf '%s\n' " mountPath: /workspaces/projets/workspace"
|
|
231
231
|
printf '%s\n' " command: [\"/bin/bash\", \"-lc\"]"
|
|
232
232
|
printf '%s\n' " args:"
|
|
233
|
-
printf '%s\n' " - 'devzone agent --local ${folder} /agent-consigne/consigne.md; code=\$?; cat \"\$
|
|
233
|
+
printf '%s\n' " - 'devzone agent --local ${folder} /agent-consigne/consigne.md; code=\$?; cat \"\$DEVZONE_ROOT/workspace/.agents/${AGENT_POD_SESSION_LABEL}.log\" 2>/dev/null; exit \$code'"
|
|
234
234
|
printf '%s\n' " volumes:"
|
|
235
235
|
printf '%s\n' " - name: workspace"
|
|
236
236
|
printf '%s\n' " persistentVolumeClaim:"
|
|
@@ -47,7 +47,7 @@ lock_trace() {
|
|
|
47
47
|
# which of the two launches succeeded in mkdir.
|
|
48
48
|
lock_take() {
|
|
49
49
|
local end age lock_pid
|
|
50
|
-
end=$(( $(date +%s) + ${
|
|
50
|
+
end=$(( $(date +%s) + ${DEVZONE_AGENT_LOCK_MAX:-10} ))
|
|
51
51
|
while ! mkdir "$AGENT_ETAT/verrou" 2>/dev/null; do
|
|
52
52
|
# A lock is orphaned only by its age: the rank is held for a few milliseconds,
|
|
53
53
|
# 30 s can only be a stop to take over; otherwise wait, then give up (code 1).
|
|
@@ -73,7 +73,7 @@ lock_take() {
|
|
|
73
73
|
if command -v flock >/dev/null 2>&1; then
|
|
74
74
|
# exec in an if makes a failure a condition instead of killing the shell
|
|
75
75
|
# (bash 3.2 and GNU alike); without flock, mkdir remains the only guard (macOS).
|
|
76
|
-
if { exec 9>"$AGENT_ETAT/rang.lock"; } && flock -w "${
|
|
76
|
+
if { exec 9>"$AGENT_ETAT/rang.lock"; } && flock -w "${DEVZONE_AGENT_LOCK_MAX:-10}" 9; then
|
|
77
77
|
AGENT_LOCK_FLOCK=1
|
|
78
78
|
else
|
|
79
79
|
lock_release
|
|
@@ -14,7 +14,7 @@ while [ -L "$SOURCE" ]; do
|
|
|
14
14
|
esac
|
|
15
15
|
done
|
|
16
16
|
ICI="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
17
|
-
RACINE="${
|
|
17
|
+
RACINE="${DEVZONE_ROOT:-$(dirname "$ICI")}"
|
|
18
18
|
|
|
19
19
|
# shellcheck source=agent-errors.sh
|
|
20
20
|
# shellcheck disable=SC1091
|
|
@@ -26,7 +26,7 @@ RACINE="${DEVZONE_RACINE:-$(dirname "$ICI")}"
|
|
|
26
26
|
# shellcheck disable=SC1091
|
|
27
27
|
. "$ICI/agent-session.sh"
|
|
28
28
|
|
|
29
|
-
AGENT_ETAT="${
|
|
29
|
+
AGENT_ETAT="${DEVZONE_AGENT_STATE:-$HOME/.local/state/oc-lancer}"
|
|
30
30
|
|
|
31
31
|
# UTC ISO-8601 date of an epoch, GNU then BSD date: the fin field of the exclusions.
|
|
32
32
|
iso() {
|
|
@@ -73,7 +73,7 @@ agent_workspace() {
|
|
|
73
73
|
echo "devzone agent: Kubernetes workspace (pod devzone-workspace-0, $in_pod); --local for the container"
|
|
74
74
|
agent_kc cp "$brief" "devzone-workspace-0:/tmp/devzone-agent-$name.md" -c workspace
|
|
75
75
|
# shellcheck disable=SC2016 # the pod shell expands MODEL_OPT, not this one
|
|
76
|
-
agent_kc exec devzone-workspace-0 -c workspace -- env
|
|
76
|
+
agent_kc exec devzone-workspace-0 -c workspace -- env DEVZONE_ROOT="$pod_root" MODEL_OPT="$MODELE_LISTE" bash -lc 'devzone agent ${MODEL_OPT:+--modele "$MODEL_OPT"} "$1" "$2"' _ "$in_pod" "/tmp/devzone-agent-$name.md" || code=$?
|
|
77
77
|
journal="$(journal_of "$name")"
|
|
78
78
|
mkdir -p "$(dirname "$journal")"
|
|
79
79
|
if ! agent_kc exec devzone-workspace-0 -c workspace -- cat "$pod_root/workspace/.agents/$name.log" >>"$journal"; then
|
package/.devcontainer/agent.sh
CHANGED
|
@@ -15,7 +15,7 @@ while [ -L "$SOURCE" ]; do
|
|
|
15
15
|
esac
|
|
16
16
|
done
|
|
17
17
|
ICI="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
18
|
-
RACINE="${
|
|
18
|
+
RACINE="${DEVZONE_ROOT:-$(dirname "$ICI")}"
|
|
19
19
|
# shellcheck source=agent-errors.sh disable=SC1091
|
|
20
20
|
. "$ICI/agent-errors.sh"
|
|
21
21
|
# shellcheck source=agent-rights.sh disable=SC1091
|
|
@@ -34,12 +34,12 @@ FREE_MODELS=(big-pickle deepseek-v4.1-flash-free hy4-flash-free nemotron-3.5-sup
|
|
|
34
34
|
# shellcheck source=agent-pod.sh disable=SC1091
|
|
35
35
|
. "$ICI/agent-pod.sh"
|
|
36
36
|
SILENCE="${DEVZONE_AGENT_SILENCE:-45}"
|
|
37
|
-
FROZEN="${
|
|
38
|
-
AGENT_ETAT="${
|
|
37
|
+
FROZEN="${DEVZONE_AGENT_FROZEN:-600}"
|
|
38
|
+
AGENT_ETAT="${DEVZONE_AGENT_STATE:-$HOME/.local/state/oc-lancer}"
|
|
39
39
|
# Pause between read and write of the rank (tests only): active only when
|
|
40
|
-
#
|
|
40
|
+
# DEVZONE_AGENT_PAUSE_RANK is set under bats; never a pause by default.
|
|
41
41
|
PAUSE_RANK=0
|
|
42
|
-
if [ -n "${
|
|
42
|
+
if [ -n "${DEVZONE_AGENT_PAUSE_RANK:-}" ] && [ -n "${BATS_TEST_TMPDIR:-}" ]; then PAUSE_RANK="$DEVZONE_AGENT_PAUSE_RANK"; fi
|
|
43
43
|
# Retries of the same session for a network cause, per model, before the next model
|
|
44
44
|
NETWORK_RETRIES=3
|
|
45
45
|
refuse() { echo "devzone agent: $*" >&2; exit 2; }
|
|
@@ -104,7 +104,7 @@ agent_launch() {
|
|
|
104
104
|
if [ "$(error_cause "$(error_lines "$new")")" != "quota" ]; then started=1; break; fi
|
|
105
105
|
fi
|
|
106
106
|
if [ $(( $(date +%s) - start_t )) -ge "$SILENCE" ]; then break; fi
|
|
107
|
-
sleep "${
|
|
107
|
+
sleep "${DEVZONE_AGENT_STEP:-1}"
|
|
108
108
|
done
|
|
109
109
|
if [ "$discard" = 1 ]; then resume; i=$(( i + 1 )); continue; fi
|
|
110
110
|
if kill -0 "$pid" 2>/dev/null && [ "$started" = 0 ]; then
|
|
@@ -127,7 +127,7 @@ agent_launch() {
|
|
|
127
127
|
size="$(wc -c <"$journal")"
|
|
128
128
|
while kill -0 "$pid" 2>/dev/null; do
|
|
129
129
|
if session_fatal_error "$pid" "$journal" "$offset" "$m" "$folder"; then discard=1; break; fi
|
|
130
|
-
sleep "${
|
|
130
|
+
sleep "${DEVZONE_AGENT_STEP:-1}"
|
|
131
131
|
now="$(date +%s)"
|
|
132
132
|
if [ "$(wc -c <"$journal")" -gt "$size" ]; then
|
|
133
133
|
size="$(wc -c <"$journal")"
|
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
# host-models.sh check update check of each model (delegates to host-check.sh)
|
|
10
10
|
# host-models.sh rapport report (delegates to host-check.sh)
|
|
11
11
|
# Default URL: http://host.docker.internal:11434, overridable with DEVZONE_OLLAMA_URL.
|
|
12
|
-
# Measurements:
|
|
12
|
+
# Measurements: DEVZONE_AI_MEASURES, else ~/.config/devzone/ia-mesures.json
|
|
13
13
|
# ({"<model>": {"reussite": 0..1, "tok_s": n, "date": "..."}}).
|
|
14
14
|
# Short timeout; exits 0 and writes nothing when Ollama does not answer.
|
|
15
15
|
# bash 3.2 (macOS). Code and comments in English.
|
|
@@ -18,7 +18,7 @@ set -euo pipefail
|
|
|
18
18
|
URL="${DEVZONE_OLLAMA_URL:-http://host.docker.internal:11434}"
|
|
19
19
|
URL="${URL%/}"
|
|
20
20
|
FILE="$HOME/.config/opencode/config.json"
|
|
21
|
-
MESURES="${
|
|
21
|
+
MESURES="${DEVZONE_AI_MEASURES:-$HOME/.config/devzone/ia-mesures.json}"
|
|
22
22
|
|
|
23
23
|
# True when a model is an embedding model (Ollama details.type, or a name
|
|
24
24
|
# containing "embed", case-insensitive).
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Each shell tool call is checked by docker-guard.sh. Exit code 2: error shown
|
|
3
3
|
// to the agent with stderr message. Script absent or failing: nothing blocked.
|
|
4
4
|
// The installed copy (devzone enable ia) replaces the placeholder below with
|
|
5
|
-
// the script path;
|
|
5
|
+
// the script path; DEVZONE_DOCKER_GUARD overrides it. The script is resolved
|
|
6
6
|
// from the plugin location itself (.devcontainer/ai/plugins -> ../docker-guard.sh).
|
|
7
7
|
// opencode 1.x also loads default exports with an id; without ctx.tool.hook the
|
|
8
8
|
// 1.x guard in devzone-guard.js remains active.
|
|
@@ -11,10 +11,10 @@ import { existsSync } from "node:fs"
|
|
|
11
11
|
import { fileURLToPath } from "node:url"
|
|
12
12
|
import { dirname, join } from "node:path"
|
|
13
13
|
|
|
14
|
-
const INSTALLED = process.env.
|
|
14
|
+
const INSTALLED = process.env.DEVZONE_DOCKER_GUARD || "__DEVZONE_DOCKER_GUARD__"
|
|
15
15
|
|
|
16
16
|
function guardScript() {
|
|
17
|
-
if (INSTALLED && INSTALLED.indexOf("
|
|
17
|
+
if (INSTALLED && INSTALLED.indexOf("__DEVZONE_DOCKER_GUARD__") !== 0 && existsSync(INSTALLED)) {
|
|
18
18
|
return INSTALLED
|
|
19
19
|
}
|
|
20
20
|
const script = join(dirname(fileURLToPath(import.meta.url)), "..", "docker-guard.sh")
|
|
@@ -2,17 +2,17 @@
|
|
|
2
2
|
// Each shell tool call is checked by docker-guard.sh. Exit code 2: error shown
|
|
3
3
|
// to the agent with stderr message. Script absent or failing: nothing blocked.
|
|
4
4
|
// The installed copy (devzone enable ia) replaces the placeholder below with
|
|
5
|
-
// the script path;
|
|
5
|
+
// the script path; DEVZONE_DOCKER_GUARD overrides it. The script is resolved
|
|
6
6
|
// from the plugin location itself (.devcontainer/ai/plugins -> ../docker-guard.sh).
|
|
7
7
|
import { spawnSync } from "node:child_process"
|
|
8
8
|
import { existsSync } from "node:fs"
|
|
9
9
|
import { fileURLToPath } from "node:url"
|
|
10
10
|
import { dirname, join } from "node:path"
|
|
11
11
|
|
|
12
|
-
const INSTALLED = process.env.
|
|
12
|
+
const INSTALLED = process.env.DEVZONE_DOCKER_GUARD || "__DEVZONE_DOCKER_GUARD__"
|
|
13
13
|
|
|
14
14
|
function guardScript() {
|
|
15
|
-
if (INSTALLED && INSTALLED.indexOf("
|
|
15
|
+
if (INSTALLED && INSTALLED.indexOf("__DEVZONE_DOCKER_GUARD__") !== 0 && existsSync(INSTALLED)) {
|
|
16
16
|
return INSTALLED
|
|
17
17
|
}
|
|
18
18
|
const script = join(dirname(fileURLToPath(import.meta.url)), "..", "docker-guard.sh")
|
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Module argocd (#411)
|
|
2
|
+
# Module argocd (#411): Argo CD in the devzone services cluster.
|
|
3
3
|
# argocd.sh install | uninstall | status | relay-start | relay-stop
|
|
4
4
|
# argocd.sh app add <repo url> [path] [--name N] [--revision R] | app list | app remove <N>
|
|
5
|
-
#
|
|
6
|
-
#
|
|
7
|
-
# .
|
|
5
|
+
# Isolated devzone-argocd namespace, relay 127.0.0.1:8443 in the container.
|
|
6
|
+
# Admin password in workspace/.argocd/admin.env (600), copied to .password;
|
|
7
|
+
# never displayed.
|
|
8
8
|
set -euo pipefail
|
|
9
9
|
|
|
10
10
|
ICI="$(cd "$(dirname "$0")" && pwd)"
|
|
11
|
-
RACINE="${
|
|
12
|
-
# shellcheck disable=SC2034 #
|
|
13
|
-
ETAT="${
|
|
11
|
+
RACINE="${DEVZONE_ROOT:-$(dirname "$(dirname "$ICI")")}"
|
|
12
|
+
# shellcheck disable=SC2034 # read by cluster.sh (sourced library)
|
|
13
|
+
ETAT="${DEVZONE_STATE:-$RACINE/.devzone.modules}"
|
|
14
14
|
# shellcheck source=SCRIPTDIR/../cluster.sh
|
|
15
15
|
# shellcheck disable=SC1091
|
|
16
16
|
. "$ICI/../cluster.sh"
|
|
17
17
|
# shellcheck source=SCRIPTDIR/../password.sh
|
|
18
18
|
# shellcheck disable=SC1091
|
|
19
19
|
. "$ICI/../password.sh"
|
|
20
|
-
#
|
|
20
|
+
# Network isolation: namespace_isolate, applied with the devzone-argocd namespace
|
|
21
21
|
# shellcheck source=SCRIPTDIR/../isolation.sh
|
|
22
22
|
# shellcheck disable=SC1091
|
|
23
23
|
. "$ICI/../isolation.sh"
|
|
@@ -29,64 +29,64 @@ ETAT="${DEVZONE_ETAT:-$RACINE/.devzone.modules}"
|
|
|
29
29
|
|
|
30
30
|
NS=devzone-argocd
|
|
31
31
|
SECRETS="$RACINE/workspace/.argocd"
|
|
32
|
-
#
|
|
32
|
+
# Pinned argo-cd chart version, relay port and install wait
|
|
33
33
|
ARGOCD_VERSION="${ARGOCD_VERSION:-10.14.0}"
|
|
34
34
|
ARGOCD_PORT="${ARGOCD_PORT:-8443}"
|
|
35
35
|
ARGOCD_ATTENTE="${ARGOCD_ATTENTE:-600}"
|
|
36
36
|
|
|
37
|
-
#
|
|
37
|
+
# Module refusal: prefixed message and code 2 (same convention as postgres)
|
|
38
38
|
refuse() { echo "devzone : argocd : $*" >&2; exit 2; }
|
|
39
39
|
|
|
40
|
-
#
|
|
41
|
-
|
|
40
|
+
# Grouped credentials view: a failure never blocks the operation
|
|
41
|
+
regenerate_credentials() {
|
|
42
42
|
password_regenerate ||
|
|
43
|
-
echo "devzone : argocd :
|
|
43
|
+
echo "devzone : argocd : grouped credentials not updated (devzone passwords)" >&2
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
#
|
|
47
|
-
# message
|
|
48
|
-
|
|
49
|
-
local
|
|
50
|
-
if !
|
|
51
|
-
echo "devzone : argocd :
|
|
46
|
+
# Refuses the install below 1 GB of allocatable memory in the cluster; the
|
|
47
|
+
# message says where to enlarge the cluster and the command to run again.
|
|
48
|
+
check_memory() {
|
|
49
|
+
local mem
|
|
50
|
+
if ! mem="$(memory_cluster_ki)"; then
|
|
51
|
+
echo "devzone : argocd : services cluster unreachable: devzone cluster" >&2
|
|
52
52
|
return 2
|
|
53
53
|
fi
|
|
54
|
-
if [ "$
|
|
55
|
-
echo "devzone : argocd :
|
|
54
|
+
if [ "$mem" -lt 1048576 ]; then
|
|
55
|
+
echo "devzone : argocd : at least 1 GB of allocatable memory is needed in the cluster (available: $((mem / 1024)) MB); enlarge the cluster (Docker Desktop → Settings → Resources) then run again: devzone enable argocd" >&2
|
|
56
56
|
return 2
|
|
57
57
|
fi
|
|
58
58
|
}
|
|
59
59
|
|
|
60
|
-
# Namespace
|
|
61
|
-
#
|
|
62
|
-
|
|
63
|
-
|
|
60
|
+
# Namespace present in the services cluster: Argo CD is installed.
|
|
61
|
+
# Reading namespaces is reserved to the administrator (#430).
|
|
62
|
+
is_installed() {
|
|
63
|
+
account_admin "$(account_context)" get namespace "$NS" >/dev/null 2>&1
|
|
64
64
|
}
|
|
65
65
|
|
|
66
|
-
#
|
|
67
|
-
#
|
|
68
|
-
|
|
66
|
+
# Creates the namespace and labels it through the administrator, allows the
|
|
67
|
+
# limited account, then applies the module's isolating NetworkPolicy (#430).
|
|
68
|
+
prepare_namespace() {
|
|
69
69
|
local ctx
|
|
70
|
-
ctx="$(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
ctx="$(account_context)"
|
|
71
|
+
account_admin "$ctx" create namespace "$NS" --dry-run=client -o yaml |
|
|
72
|
+
account_admin "$ctx" apply -f - >/dev/null
|
|
73
|
+
account_admin "$ctx" label namespace "$NS" "$CLUSTER_LABEL" --overwrite >/dev/null
|
|
74
|
+
account_allow "$ctx" "$NS"
|
|
75
|
+
namespace_isolate "$NS"
|
|
76
76
|
}
|
|
77
77
|
|
|
78
|
-
#
|
|
79
|
-
# workspace/.argocd/admin.env (600)
|
|
80
|
-
|
|
81
|
-
local
|
|
82
|
-
if !
|
|
78
|
+
# Reads the initial password from the chart's Secret and writes it to
|
|
79
|
+
# workspace/.argocd/admin.env (600); the content is never displayed.
|
|
80
|
+
save_admin() {
|
|
81
|
+
local raw pw
|
|
82
|
+
if ! raw="$(kubectl --context devzone -n "$NS" get secret argocd-initial-admin-secret \
|
|
83
83
|
-o jsonpath='{.data.password}' 2>/dev/null)"; then
|
|
84
|
-
echo "devzone : argocd : secret argocd-initial-admin-secret
|
|
84
|
+
echo "devzone : argocd : secret argocd-initial-admin-secret not found" >&2
|
|
85
85
|
return 1
|
|
86
86
|
fi
|
|
87
|
-
|
|
88
|
-
if [ -z "$
|
|
89
|
-
echo "devzone : argocd :
|
|
87
|
+
pw="$(printf '%s' "$raw" | base64 -d 2>/dev/null || true)"
|
|
88
|
+
if [ -z "$pw" ]; then
|
|
89
|
+
echo "devzone : argocd : admin password unreadable in the secret" >&2
|
|
90
90
|
return 1
|
|
91
91
|
fi
|
|
92
92
|
mkdir -p "$SECRETS"
|
|
@@ -96,71 +96,72 @@ enregistrer_admin() {
|
|
|
96
96
|
cat >"$SECRETS/admin.env" <<ENV
|
|
97
97
|
ARGOCD_URL=https://127.0.0.1:$ARGOCD_PORT
|
|
98
98
|
ARGOCD_USER=admin
|
|
99
|
-
ARGOCD_PASSWORD=$
|
|
99
|
+
ARGOCD_PASSWORD=$pw
|
|
100
100
|
ENV
|
|
101
101
|
)
|
|
102
102
|
chmod 600 "$SECRETS/admin.env"
|
|
103
103
|
}
|
|
104
104
|
|
|
105
|
-
#
|
|
106
|
-
#
|
|
107
|
-
|
|
108
|
-
echo "▶
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
echo "▶
|
|
105
|
+
# Installs Argo CD with the pinned chart, prepares the namespace, stores the
|
|
106
|
+
# admin password and starts the access relay; idempotent (upgrade --install).
|
|
107
|
+
do_install() {
|
|
108
|
+
echo "▶ Checking the allocatable memory of the services cluster…"
|
|
109
|
+
check_memory || return 2
|
|
110
|
+
prepare_namespace
|
|
111
|
+
echo "▶ Installing Argo CD $ARGOCD_VERSION in $NS (chart charts/devzone-argocd)…"
|
|
112
112
|
# Wrapper chart: the dependency argo-cd (pinned in Chart.yaml) is built
|
|
113
113
|
# first, then installed from the local chart (#538)
|
|
114
114
|
helm dependency build "$RACINE/charts/devzone-argocd" >/dev/null
|
|
115
|
-
|
|
115
|
+
account_helm "$(account_context)" upgrade --install argocd \
|
|
116
116
|
"$RACINE/charts/devzone-argocd" \
|
|
117
117
|
--namespace "$NS" \
|
|
118
118
|
--create-namespace \
|
|
119
119
|
--timeout "${ARGOCD_ATTENTE}s" \
|
|
120
120
|
--wait
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
echo "✔
|
|
121
|
+
save_admin
|
|
122
|
+
relay_start argocd devzone "$NS" svc/argocd-server "$ARGOCD_PORT:443"
|
|
123
|
+
regenerate_credentials
|
|
124
|
+
echo "✔ argocd module ready: https://127.0.0.1:$ARGOCD_PORT"
|
|
125
125
|
}
|
|
126
126
|
|
|
127
|
-
#
|
|
128
|
-
#
|
|
129
|
-
#
|
|
130
|
-
|
|
127
|
+
# Uninstalls the Helm release and deletes the namespace; the other services
|
|
128
|
+
# of the cluster stay, under direct helm. The RoleBinding and the namespace
|
|
129
|
+
# are removed by the administrator (#430).
|
|
130
|
+
do_uninstall() {
|
|
131
131
|
local ctx
|
|
132
|
-
|
|
133
|
-
if
|
|
134
|
-
echo "▶
|
|
135
|
-
if !
|
|
136
|
-
echo "devzone : argocd : helm uninstall
|
|
132
|
+
relay_stop argocd
|
|
133
|
+
if is_installed; then
|
|
134
|
+
echo "▶ Deleting Argo CD on the services cluster…"
|
|
135
|
+
if ! account_helm "$(account_context)" uninstall argocd -n "$NS" >/dev/null 2>&1; then
|
|
136
|
+
echo "devzone : argocd : helm uninstall failed (release already absent?)" >&2
|
|
137
137
|
fi
|
|
138
|
-
ctx="$(
|
|
139
|
-
|
|
140
|
-
|
|
138
|
+
ctx="$(account_context)"
|
|
139
|
+
account_remove "$ctx" "$NS" >/dev/null 2>&1 || true
|
|
140
|
+
account_admin "$ctx" delete namespace "$NS" --wait=true >/dev/null
|
|
141
141
|
fi
|
|
142
142
|
rm -rf "$SECRETS"
|
|
143
|
-
echo "✔
|
|
144
|
-
|
|
143
|
+
echo "✔ argocd module disabled; the services stay, under direct helm."
|
|
144
|
+
regenerate_credentials
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
#
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
147
|
+
# Module status: disabled without namespace, ready with the relay active.
|
|
148
|
+
# The status texts are read by devzone: keep them unchanged.
|
|
149
|
+
do_status() {
|
|
150
|
+
if ! is_installed; then
|
|
151
|
+
echo "disabled"
|
|
151
152
|
return 0
|
|
152
153
|
fi
|
|
153
|
-
if !
|
|
154
|
-
echo "
|
|
154
|
+
if ! relay_active argocd; then
|
|
155
|
+
echo "ready, relay stopped: devzone apply"
|
|
155
156
|
else
|
|
156
|
-
echo "
|
|
157
|
+
echo "ready: https://127.0.0.1:$ARGOCD_PORT"
|
|
157
158
|
fi
|
|
158
159
|
}
|
|
159
160
|
|
|
160
|
-
#
|
|
161
|
-
|
|
162
|
-
if
|
|
163
|
-
|
|
161
|
+
# Starts the access relay again only if the Argo CD namespace exists.
|
|
162
|
+
do_relay_start() {
|
|
163
|
+
if is_installed; then
|
|
164
|
+
relay_start argocd devzone "$NS" svc/argocd-server "$ARGOCD_PORT:443"
|
|
164
165
|
fi
|
|
165
166
|
}
|
|
166
167
|
|
|
@@ -192,26 +193,26 @@ ARGOCD_CONF="${DEVZONE_ARGOCD_CONF:-$RACINE/.argocd.conf}"
|
|
|
192
193
|
argocd_kubectl() { kubectl --context devzone "$@"; }
|
|
193
194
|
|
|
194
195
|
case "${1:-}" in
|
|
195
|
-
install)
|
|
196
|
-
uninstall)
|
|
197
|
-
status)
|
|
198
|
-
relay-start)
|
|
199
|
-
relay-stop)
|
|
196
|
+
install) do_install ;;
|
|
197
|
+
uninstall) do_uninstall ;;
|
|
198
|
+
status) do_status ;;
|
|
199
|
+
relay-start) do_relay_start ;;
|
|
200
|
+
relay-stop) relay_stop argocd ;;
|
|
200
201
|
init)
|
|
201
202
|
# GitOps repository of the user (#516): created or designated, then
|
|
202
203
|
# the root Application when the module is installed
|
|
203
204
|
gitops_init "${@:2}" || exit $?
|
|
204
|
-
if
|
|
205
|
+
if is_installed; then gitops_root; fi
|
|
205
206
|
;;
|
|
206
207
|
apply)
|
|
207
|
-
|
|
208
|
+
is_installed || refuse "module off: devzone enable argocd"
|
|
208
209
|
gitops_init && gitops_root && apps_reconcile
|
|
209
210
|
;;
|
|
210
211
|
app)
|
|
211
212
|
if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
|
|
212
213
|
refuse "in the workspace pod, on the workstation: devzone workspace argocd app ${*:2}"
|
|
213
214
|
fi
|
|
214
|
-
|
|
215
|
+
is_installed || refuse "module off: devzone enable argocd"
|
|
215
216
|
argocd_app "${@:2}"
|
|
216
217
|
;;
|
|
217
218
|
*)
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
# Argo CD for the catalogue applications in the container (#538): the module
|
|
3
3
|
# mysql and the catalogue install their application as the Application
|
|
4
4
|
# devzone-<app> (services.sh) when the module argocd is active, instead of
|
|
5
|
-
# the manifest applied by hand. The namespace (
|
|
5
|
+
# the manifest applied by hand. The namespace (account_namespace of
|
|
6
6
|
# cluster.sh, isolation.sh) and the secret <app>-admin (mirror
|
|
7
7
|
# workspace/.<app>/) stay created apart, out of Git; Argo CD holds the chart
|
|
8
8
|
# charts/devzone-<app> of the devzone repository at the revision.
|
|
@@ -79,7 +79,7 @@ catalogue_argocd_active() {
|
|
|
79
79
|
local app="$1"
|
|
80
80
|
catalogue_argocd_module_on || return 1
|
|
81
81
|
[ -d "$RACINE/charts/devzone-$app" ] || return 1
|
|
82
|
-
|
|
82
|
+
account_admin "$(account_context)" get namespace devzone-argocd >/dev/null 2>&1 || return 1
|
|
83
83
|
catalogue_argocd_load
|
|
84
84
|
[ -n "$(argocd_revision)" ]
|
|
85
85
|
}
|
|
@@ -16,11 +16,11 @@
|
|
|
16
16
|
|
|
17
17
|
ICI="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
18
18
|
# RACINE: the code tree (libraries, charts); STATE_RACINE: the devzone folder
|
|
19
|
-
# (workspace/ secrets, .argocd.conf), the same folder unless
|
|
19
|
+
# (workspace/ secrets, .argocd.conf), the same folder unless DEVZONE_ROOT says so
|
|
20
20
|
RACINE="$(dirname "$(dirname "$ICI")")"
|
|
21
|
-
STATE_RACINE="${
|
|
21
|
+
STATE_RACINE="${DEVZONE_ROOT:-$RACINE}"
|
|
22
22
|
# shellcheck disable=SC2034 # read by catalog-argocd.sh
|
|
23
|
-
ETAT="${
|
|
23
|
+
ETAT="${DEVZONE_STATE:-$STATE_RACINE/.devzone.modules}"
|
|
24
24
|
APP_CONF="$RACINE/.devcontainer/catalog/mysql/app.conf"
|
|
25
25
|
HOOK_SERVICES="postgres mysql"
|
|
26
26
|
|
|
@@ -44,7 +44,7 @@ chart_require() {
|
|
|
44
44
|
if [ -f "$chart/Chart.yaml" ] && grep -qxF "name: devzone-$svc" "$chart/Chart.yaml"; then
|
|
45
45
|
return 0
|
|
46
46
|
fi
|
|
47
|
-
echo "✖ $svc : chart charts/devzone-$svc missing or misnamed (manage/docs/reference.md#charts
|
|
47
|
+
echo "✖ $svc : chart charts/devzone-$svc missing or misnamed (manage/docs/reference.md#devzone-charts)" >&2
|
|
48
48
|
return 2
|
|
49
49
|
}
|
|
50
50
|
|