devzone 0.47.0 → 0.48.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/agent-pod-manifest.sh +247 -0
- package/.devcontainer/agent-pod.sh +213 -0
- package/.devcontainer/agent.sh +14 -15
- package/.devcontainer/devzone +1 -1
- package/README.md +4 -0
- package/manage/devzone +1 -1
- package/manage/scripts/workspace-aliases.sh +1 -0
- package/manage/scripts/workspace-update.sh +106 -0
- package/manage/workspace.sh +9 -9
- package/package.json +1 -1
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Manifest and validation helpers for the ephemeral session pod (#222).
|
|
3
|
+
# Sourced by agent-pod.sh.
|
|
4
|
+
# bash 3.2 compatible ; shellcheck -x clean.
|
|
5
|
+
|
|
6
|
+
# --- Defaults ---
|
|
7
|
+
|
|
8
|
+
DEVZONE_AGENT_POD_ACTIVE_DEADLINE_SECONDS="${DEVZONE_AGENT_POD_ACTIVE_DEADLINE_SECONDS:-1800}"
|
|
9
|
+
DEVZONE_AGENT_POD_CPU_LIMIT="${DEVZONE_AGENT_POD_CPU_LIMIT:-2}"
|
|
10
|
+
DEVZONE_AGENT_POD_MEM_LIMIT="${DEVZONE_AGENT_POD_MEM_LIMIT:-4Gi}"
|
|
11
|
+
DEVZONE_AGENT_POD_TIMEOUT="${DEVZONE_AGENT_POD_TIMEOUT:-$((DEVZONE_AGENT_POD_ACTIVE_DEADLINE_SECONDS + 120))}"
|
|
12
|
+
# Projects root, read by the launcher only (no trailing slash). The pod keeps
|
|
13
|
+
# /workspaces/projets in its own environment (DEVZONE_RACINE in the manifest).
|
|
14
|
+
AGENT_POD_ROOT="${DEVZONE_RACINE:-/workspaces/projets}"
|
|
15
|
+
# Module state file on the workspace volume (subPath .devzone.modules, read-only in the pod).
|
|
16
|
+
# shellcheck disable=SC2034 # read by agent-pod.sh
|
|
17
|
+
AGENT_POD_MODULES_FILE="${DEVZONE_AGENT_POD_MODULES_FILE:-${AGENT_POD_ROOT}/.devzone.modules}"
|
|
18
|
+
|
|
19
|
+
# --- Path check : under AGENT_POD_ROOT, only [A-Za-z0-9._/-], no . or .. part ---
|
|
20
|
+
|
|
21
|
+
agent_pod_path_ok() {
|
|
22
|
+
printf '%s' "$AGENT_POD_ROOT" | grep -Eq '^/[A-Za-z0-9._/-]*[A-Za-z0-9._-]$' || return 1
|
|
23
|
+
case "$1" in "$AGENT_POD_ROOT"/*) ;; *) return 1 ;; esac
|
|
24
|
+
printf '%s' "$1" | grep -Eq '^[A-Za-z0-9._/-]+$' || return 1
|
|
25
|
+
case "$1/" in */./* | */../* | *//*) return 1 ;; esac
|
|
26
|
+
return 0
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
# --- State filled by agent_pod_validate_folder ---
|
|
30
|
+
|
|
31
|
+
AGENT_POD_WORKTREE_SUBPATH=""
|
|
32
|
+
AGENT_POD_WORKTREE_MOUNTPATH=""
|
|
33
|
+
AGENT_POD_GIT_SUBPATH=""
|
|
34
|
+
AGENT_POD_GIT_MOUNTPATH=""
|
|
35
|
+
AGENT_POD_SESSION_LABEL=""
|
|
36
|
+
AGENT_POD_TICKET=""
|
|
37
|
+
|
|
38
|
+
# --- Helpers : read the workspace pod (devzone-workspace-0, container workspace) ---
|
|
39
|
+
|
|
40
|
+
agent_pod_image_workspace() {
|
|
41
|
+
local result
|
|
42
|
+
result="$(kubectl get pod devzone-workspace-0 -o jsonpath='{.spec.containers[?(@.name=="workspace")].image}' 2>/dev/null)" || true
|
|
43
|
+
echo "${result:-ghcr.io/simbienvenuehoulboumi/devzone-workspace:latest}"
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
agent_pod_path_workspace() {
|
|
47
|
+
local result
|
|
48
|
+
result="$(kubectl get pod devzone-workspace-0 -o jsonpath='{.spec.containers[?(@.name=="workspace")].env[?(@.name=="PATH")].value}' 2>/dev/null)" || true
|
|
49
|
+
echo "${result:-/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin}"
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
agent_pod_pvc_workspace() {
|
|
53
|
+
local result
|
|
54
|
+
result="$(kubectl get pod devzone-workspace-0 -o jsonpath='{.spec.volumes[?(@.name=="workspace")].persistentVolumeClaim.claimName}' 2>/dev/null)" || true
|
|
55
|
+
echo "${result:-workspace-devzone-workspace-0}"
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
agent_pod_pvc_etat() {
|
|
59
|
+
local result
|
|
60
|
+
result="$(kubectl get pod devzone-workspace-0 -o jsonpath='{.spec.volumes[?(@.name=="etat")].persistentVolumeClaim.claimName}' 2>/dev/null)" || true
|
|
61
|
+
echo "${result:-etat-devzone-workspace-0}"
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
# --- Validation of the folder to session ---
|
|
65
|
+
|
|
66
|
+
agent_pod_validate_folder() {
|
|
67
|
+
local folder="$1" gitfile gitdir common base
|
|
68
|
+
if [ -z "$folder" ]; then
|
|
69
|
+
echo "devzone agent --pod : folder missing" >&2
|
|
70
|
+
return 1
|
|
71
|
+
fi
|
|
72
|
+
case "$folder" in
|
|
73
|
+
"$AGENT_POD_ROOT"/*) ;;
|
|
74
|
+
*)
|
|
75
|
+
echo "devzone agent --pod : folder outside the projects root $AGENT_POD_ROOT : $folder" >&2
|
|
76
|
+
return 1
|
|
77
|
+
;;
|
|
78
|
+
esac
|
|
79
|
+
if ! agent_pod_path_ok "$folder"; then
|
|
80
|
+
echo "devzone agent --pod : invalid folder path : $folder" >&2
|
|
81
|
+
return 1
|
|
82
|
+
fi
|
|
83
|
+
gitfile="$folder/.git"
|
|
84
|
+
if [ ! -f "$gitfile" ]; then
|
|
85
|
+
echo "devzone agent --pod : no .git file (not a git worktree) : $folder" >&2
|
|
86
|
+
return 1
|
|
87
|
+
fi
|
|
88
|
+
gitdir="$(grep '^gitdir:' "$gitfile" 2>/dev/null | head -1 | sed 's/^gitdir:[[:space:]]*//;s/[[:space:]]*$//')"
|
|
89
|
+
if [ -z "$gitdir" ]; then
|
|
90
|
+
echo "devzone agent --pod : .git without gitdir line : $folder" >&2
|
|
91
|
+
return 1
|
|
92
|
+
fi
|
|
93
|
+
case "$gitdir" in
|
|
94
|
+
*/worktrees/*) common="${gitdir%/worktrees/*}" ;;
|
|
95
|
+
*)
|
|
96
|
+
echo "devzone agent --pod : gitdir is not a worktree : $gitdir" >&2
|
|
97
|
+
return 1
|
|
98
|
+
;;
|
|
99
|
+
esac
|
|
100
|
+
case "$common" in
|
|
101
|
+
"$AGENT_POD_ROOT"/*) ;;
|
|
102
|
+
*)
|
|
103
|
+
echo "devzone agent --pod : worktree depot outside the projects root $AGENT_POD_ROOT : $common" >&2
|
|
104
|
+
return 1
|
|
105
|
+
;;
|
|
106
|
+
esac
|
|
107
|
+
if ! agent_pod_path_ok "$common"; then
|
|
108
|
+
echo "devzone agent --pod : invalid depot path : $common" >&2
|
|
109
|
+
return 1
|
|
110
|
+
fi
|
|
111
|
+
base="$(basename "$folder")"
|
|
112
|
+
if ! printf '%s' "$base" | grep -Eq '^[A-Za-z0-9]([A-Za-z0-9._-]*[A-Za-z0-9])?$'; then
|
|
113
|
+
echo "devzone agent --pod : invalid label value : $base" >&2
|
|
114
|
+
return 1
|
|
115
|
+
fi
|
|
116
|
+
if [ "${#base}" -gt 63 ]; then
|
|
117
|
+
echo "devzone agent --pod : label value too long : $base" >&2
|
|
118
|
+
return 1
|
|
119
|
+
fi
|
|
120
|
+
AGENT_POD_WORKTREE_MOUNTPATH="$folder"
|
|
121
|
+
AGENT_POD_WORKTREE_SUBPATH="${folder#"$AGENT_POD_ROOT"/}"
|
|
122
|
+
AGENT_POD_GIT_MOUNTPATH="$common"
|
|
123
|
+
AGENT_POD_GIT_SUBPATH="${common#"$AGENT_POD_ROOT"/}"
|
|
124
|
+
AGENT_POD_SESSION_LABEL="$base"
|
|
125
|
+
# Keep the ticket only for an exact dz-<number> name.
|
|
126
|
+
if ! printf '%s' "$base" | grep -Eq '^dz-[0-9]+$'; then
|
|
127
|
+
AGENT_POD_TICKET=""
|
|
128
|
+
else
|
|
129
|
+
AGENT_POD_TICKET="${base#dz-}"
|
|
130
|
+
fi
|
|
131
|
+
return 0
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
# --- Build the session pod manifest ---
|
|
135
|
+
|
|
136
|
+
agent_pod_build_manifest() {
|
|
137
|
+
# $2 (the consigne) is never written here: it only goes to the ConfigMap.
|
|
138
|
+
local folder="$1" pod_name="$3"
|
|
139
|
+
local ws_image ws_path pvc_workspace pvc_etat manifest_file ticket_block=""
|
|
140
|
+
|
|
141
|
+
ws_image="$(agent_pod_image_workspace)"
|
|
142
|
+
ws_path="$(agent_pod_path_workspace)"
|
|
143
|
+
pvc_workspace="$(agent_pod_pvc_workspace)"
|
|
144
|
+
pvc_etat="$(agent_pod_pvc_etat)"
|
|
145
|
+
|
|
146
|
+
if [ -n "$AGENT_POD_TICKET" ]; then
|
|
147
|
+
ticket_block=" devzone.io/agent-ticket: \"${AGENT_POD_TICKET}\""
|
|
148
|
+
fi
|
|
149
|
+
|
|
150
|
+
manifest_file="$(mktemp "${TMPDIR:-/tmp}/devzone-agent-pod-manifest.XXXXXX.yaml")"
|
|
151
|
+
|
|
152
|
+
{
|
|
153
|
+
printf '%s\n' "apiVersion: v1"
|
|
154
|
+
printf '%s\n' "kind: Pod"
|
|
155
|
+
printf '%s\n' "metadata:"
|
|
156
|
+
printf '%s\n' " name: ${pod_name}"
|
|
157
|
+
printf '%s\n' " labels:"
|
|
158
|
+
printf '%s\n' " devzone.io/agent-session: ${AGENT_POD_SESSION_LABEL}"
|
|
159
|
+
if [ -n "$ticket_block" ]; then
|
|
160
|
+
printf '%s\n' "$ticket_block"
|
|
161
|
+
fi
|
|
162
|
+
printf '%s\n' "spec:"
|
|
163
|
+
printf '%s\n' " restartPolicy: Never"
|
|
164
|
+
printf '%s\n' " activeDeadlineSeconds: ${DEVZONE_AGENT_POD_ACTIVE_DEADLINE_SECONDS}"
|
|
165
|
+
printf '%s\n' " automountServiceAccountToken: false"
|
|
166
|
+
printf '%s\n' " securityContext:"
|
|
167
|
+
printf '%s\n' " runAsUser: 1000"
|
|
168
|
+
printf '%s\n' " runAsGroup: 1000"
|
|
169
|
+
printf '%s\n' " runAsNonRoot: true"
|
|
170
|
+
printf '%s\n' " fsGroup: 1000"
|
|
171
|
+
printf '%s\n' " affinity:"
|
|
172
|
+
printf '%s\n' " podAffinity:"
|
|
173
|
+
printf '%s\n' " requiredDuringSchedulingIgnoredDuringExecution:"
|
|
174
|
+
printf '%s\n' " - labelSelector:"
|
|
175
|
+
printf '%s\n' " matchExpressions:"
|
|
176
|
+
printf '%s\n' " - key: statefulset.kubernetes.io/pod-name"
|
|
177
|
+
printf '%s\n' " operator: In"
|
|
178
|
+
printf '%s\n' " values:"
|
|
179
|
+
printf '%s\n' " - devzone-workspace-0"
|
|
180
|
+
printf '%s\n' " topologyKey: kubernetes.io/hostname"
|
|
181
|
+
printf '%s\n' " containers:"
|
|
182
|
+
printf '%s\n' " - name: agent"
|
|
183
|
+
printf '%s\n' " image: ${ws_image}"
|
|
184
|
+
printf '%s\n' " env:"
|
|
185
|
+
printf '%s\n' " - name: HOME"
|
|
186
|
+
printf '%s\n' " value: \"/home/vscode\""
|
|
187
|
+
printf '%s\n' " - name: NPM_CONFIG_PREFIX"
|
|
188
|
+
printf '%s\n' " value: \"/home/vscode/.local/npm\""
|
|
189
|
+
printf '%s\n' " - name: PATH"
|
|
190
|
+
printf '%s\n' " value: \"${ws_path}\""
|
|
191
|
+
printf '%s\n' " - name: DEVZONE_WORKSPACE"
|
|
192
|
+
printf '%s\n' " value: \"kubernetes\""
|
|
193
|
+
printf '%s\n' " - name: DEVZONE_RACINE"
|
|
194
|
+
printf '%s\n' " value: \"/workspaces/projets\""
|
|
195
|
+
printf '%s\n' " resources:"
|
|
196
|
+
printf '%s\n' " limits:"
|
|
197
|
+
printf '%s\n' " cpu: ${DEVZONE_AGENT_POD_CPU_LIMIT}"
|
|
198
|
+
printf '%s\n' " memory: ${DEVZONE_AGENT_POD_MEM_LIMIT}"
|
|
199
|
+
printf '%s\n' " volumeMounts:"
|
|
200
|
+
printf '%s\n' " - name: workspace"
|
|
201
|
+
printf '%s\n' " mountPath: ${AGENT_POD_WORKTREE_MOUNTPATH}"
|
|
202
|
+
printf '%s\n' " subPath: ${AGENT_POD_WORKTREE_SUBPATH}"
|
|
203
|
+
printf '%s\n' " - name: workspace"
|
|
204
|
+
printf '%s\n' " mountPath: ${AGENT_POD_GIT_MOUNTPATH}"
|
|
205
|
+
printf '%s\n' " subPath: ${AGENT_POD_GIT_SUBPATH}"
|
|
206
|
+
printf '%s\n' " - name: workspace"
|
|
207
|
+
printf '%s\n' " mountPath: /workspaces/projets/.devzone.modules"
|
|
208
|
+
printf '%s\n' " subPath: .devzone.modules"
|
|
209
|
+
printf '%s\n' " readOnly: true"
|
|
210
|
+
printf '%s\n' " - name: etat"
|
|
211
|
+
printf '%s\n' " mountPath: /home/vscode/.config/opencode"
|
|
212
|
+
printf '%s\n' " subPath: .config/opencode"
|
|
213
|
+
printf '%s\n' " - name: etat"
|
|
214
|
+
printf '%s\n' " mountPath: /home/vscode/.local/share/opencode"
|
|
215
|
+
printf '%s\n' " subPath: .local/share/opencode"
|
|
216
|
+
printf '%s\n' " - name: etat"
|
|
217
|
+
printf '%s\n' " mountPath: /home/vscode/.local/state/oc-lancer"
|
|
218
|
+
printf '%s\n' " subPath: .local/state/oc-lancer"
|
|
219
|
+
printf '%s\n' " - name: etat"
|
|
220
|
+
printf '%s\n' " mountPath: /home/vscode/.local/npm"
|
|
221
|
+
printf '%s\n' " subPath: .local/npm"
|
|
222
|
+
printf '%s\n' " readOnly: true"
|
|
223
|
+
printf '%s\n' " - name: consigne"
|
|
224
|
+
printf '%s\n' " mountPath: /agent-consigne"
|
|
225
|
+
printf '%s\n' " readOnly: true"
|
|
226
|
+
printf '%s\n' " - name: session-workspace"
|
|
227
|
+
printf '%s\n' " mountPath: /workspaces/projets/workspace"
|
|
228
|
+
printf '%s\n' " command: [\"/bin/bash\", \"-lc\"]"
|
|
229
|
+
printf '%s\n' " args:"
|
|
230
|
+
printf '%s\n' " - 'devzone agent --local ${folder} /agent-consigne/consigne.md; code=\$?; cat \"\$DEVZONE_RACINE/workspace/.agents/${AGENT_POD_SESSION_LABEL}.log\" 2>/dev/null; exit \$code'"
|
|
231
|
+
printf '%s\n' " volumes:"
|
|
232
|
+
printf '%s\n' " - name: workspace"
|
|
233
|
+
printf '%s\n' " persistentVolumeClaim:"
|
|
234
|
+
printf '%s\n' " claimName: ${pvc_workspace}"
|
|
235
|
+
printf '%s\n' " - name: etat"
|
|
236
|
+
printf '%s\n' " persistentVolumeClaim:"
|
|
237
|
+
printf '%s\n' " claimName: ${pvc_etat}"
|
|
238
|
+
printf '%s\n' " - name: consigne"
|
|
239
|
+
printf '%s\n' " configMap:"
|
|
240
|
+
printf '%s\n' " name: ${pod_name}-consigne"
|
|
241
|
+
printf '%s\n' " - name: session-workspace"
|
|
242
|
+
printf '%s\n' " emptyDir:"
|
|
243
|
+
printf '%s\n' " sizeLimit: 256Mi"
|
|
244
|
+
} >"$manifest_file"
|
|
245
|
+
|
|
246
|
+
echo "$manifest_file"
|
|
247
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# Ephemeral session pod for devzone agent (#222).
|
|
3
|
+
# Sourced by agent.sh: launches the session pod (devzone agent --pod), waits for
|
|
4
|
+
# its end, keeps its log, deletes the pod and its ConfigMap, lists session pods (status).
|
|
5
|
+
#
|
|
6
|
+
# Constraints:
|
|
7
|
+
# - bash 3.2 compatible
|
|
8
|
+
# - shellcheck -x clean
|
|
9
|
+
# - no real cluster: kubectl is faked in tests
|
|
10
|
+
# - the pod and its ConfigMap are always deleted (EXIT, INT, TERM trap)
|
|
11
|
+
|
|
12
|
+
ICI="${ICI:-$(cd -P "$(dirname "${BASH_SOURCE[0]}")" && pwd)}"
|
|
13
|
+
# shellcheck source=agent-pod-manifest.sh disable=SC1091
|
|
14
|
+
. "${ICI}/agent-pod-manifest.sh"
|
|
15
|
+
|
|
16
|
+
# Resources of the current launch, read by the cleanup trap.
|
|
17
|
+
AGENT_POD_ACTIVE_NAME=""
|
|
18
|
+
AGENT_POD_ACTIVE_MANIFEST=""
|
|
19
|
+
AGENT_POD_CLEANED=0
|
|
20
|
+
|
|
21
|
+
# --- Pod and ConfigMap names ---
|
|
22
|
+
|
|
23
|
+
agent_pod_name() {
|
|
24
|
+
local base="${1:-}"
|
|
25
|
+
if [ -z "$base" ]; then
|
|
26
|
+
base="${AGENT_POD_SESSION_LABEL:-session}"
|
|
27
|
+
else
|
|
28
|
+
base="$(basename "$base")"
|
|
29
|
+
fi
|
|
30
|
+
# Kubernetes object names must be lowercase.
|
|
31
|
+
base="$(printf '%s' "$base" | tr '[:upper:]' '[:lower:]')"
|
|
32
|
+
echo "agent-${base}-$RANDOM"
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
agent_pod_configmap_name() {
|
|
36
|
+
echo "$1-consigne"
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
agent_pod_create_configmap() {
|
|
40
|
+
local pod_name="$1" consigne_file="$2"
|
|
41
|
+
kubectl create configmap "$(agent_pod_configmap_name "$pod_name")" \
|
|
42
|
+
--from-file=consigne.md="$consigne_file" >/dev/null 2>&1
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
agent_pod_delete_configmap() {
|
|
46
|
+
local pod_name="$1"
|
|
47
|
+
kubectl delete configmap "$(agent_pod_configmap_name "$pod_name")" >/dev/null 2>&1 || true
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
# --- Create the pod ---
|
|
51
|
+
|
|
52
|
+
agent_pod_create() {
|
|
53
|
+
local manifest_file="$1"
|
|
54
|
+
kubectl create -f "$manifest_file" >/dev/null 2>&1
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
# --- Wait for the pod to finish ---
|
|
58
|
+
|
|
59
|
+
agent_pod_wait() {
|
|
60
|
+
local pod_name="$1"
|
|
61
|
+
local elapsed=0
|
|
62
|
+
local max_wait="$DEVZONE_AGENT_POD_TIMEOUT"
|
|
63
|
+
local phase=""
|
|
64
|
+
|
|
65
|
+
while [ "$elapsed" -lt "$max_wait" ]; do
|
|
66
|
+
phase="$(kubectl get pod "$pod_name" -o jsonpath='{.status.phase}' 2>/dev/null)" || true
|
|
67
|
+
if [ "$phase" = "Succeeded" ] || [ "$phase" = "Failed" ]; then
|
|
68
|
+
echo "$phase"
|
|
69
|
+
return 0
|
|
70
|
+
fi
|
|
71
|
+
sleep 1
|
|
72
|
+
elapsed=$((elapsed + 1))
|
|
73
|
+
done
|
|
74
|
+
|
|
75
|
+
phase="$(kubectl get pod "$pod_name" -o jsonpath='{.status.phase}' 2>/dev/null)" || true
|
|
76
|
+
echo "${phase:-Unknown}"
|
|
77
|
+
return 1
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# --- Keep the log of the session ---
|
|
81
|
+
|
|
82
|
+
agent_pod_fetch_logs() {
|
|
83
|
+
local pod_name="$1" journal_file="$2"
|
|
84
|
+
kubectl logs "$pod_name" >>"$journal_file" 2>/dev/null || true
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
# Last lines of the log on stderr: the cause of a failure is there.
|
|
88
|
+
agent_pod_show_tail() {
|
|
89
|
+
local journal_file="$1"
|
|
90
|
+
tail -n 15 "$journal_file" >&2 || true
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
# --- Delete the pod ---
|
|
94
|
+
|
|
95
|
+
agent_pod_delete() {
|
|
96
|
+
local pod_name="$1"
|
|
97
|
+
kubectl delete pod "$pod_name" >/dev/null 2>&1 || true
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
# --- Status : list session pods with their limits ---
|
|
101
|
+
|
|
102
|
+
agent_pod_status() {
|
|
103
|
+
kubectl get pods -l "devzone.io/agent-session" \
|
|
104
|
+
-o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.containers[0].resources.limits.cpu}{"\t"}{.spec.containers[0].resources.limits.memory}{"\n"}{end}' 2>/dev/null || true
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
# --- Cleanup trap: pod, ConfigMap, temporary manifest (not the log) ---
|
|
108
|
+
|
|
109
|
+
agent_pod_cleanup() {
|
|
110
|
+
if [ "$AGENT_POD_CLEANED" = 1 ]; then
|
|
111
|
+
return 0
|
|
112
|
+
fi
|
|
113
|
+
AGENT_POD_CLEANED=1
|
|
114
|
+
if [ -n "$AGENT_POD_ACTIVE_NAME" ]; then
|
|
115
|
+
agent_pod_delete "$AGENT_POD_ACTIVE_NAME"
|
|
116
|
+
agent_pod_delete_configmap "$AGENT_POD_ACTIVE_NAME"
|
|
117
|
+
fi
|
|
118
|
+
if [ -n "$AGENT_POD_ACTIVE_MANIFEST" ]; then
|
|
119
|
+
rm -f "$AGENT_POD_ACTIVE_MANIFEST"
|
|
120
|
+
fi
|
|
121
|
+
return 0
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
# Set before any object is created. INT and TERM leave with 130 / 143;
|
|
125
|
+
# EXIT keeps the exit code of the script.
|
|
126
|
+
agent_pod_set_trap() {
|
|
127
|
+
trap 'agent_pod_cleanup' EXIT
|
|
128
|
+
trap 'agent_pod_cleanup; exit 130' INT
|
|
129
|
+
trap 'agent_pod_cleanup; exit 143' TERM
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
# --- Launch a session agent in an ephemeral pod (devzone agent --pod) ---
|
|
133
|
+
|
|
134
|
+
agent_pod_lancer() {
|
|
135
|
+
local folder_raw="${1:-}" consigne_raw="${2:-}"
|
|
136
|
+
local folder consigne pod_name journal_file phase manifest_file etat
|
|
137
|
+
local rc=0
|
|
138
|
+
|
|
139
|
+
if [ "${DEVZONE_WORKSPACE:-}" != "kubernetes" ]; then
|
|
140
|
+
echo "devzone agent --pod : must be called from the workspace pod (DEVZONE_WORKSPACE=kubernetes)" >&2
|
|
141
|
+
exit 1
|
|
142
|
+
fi
|
|
143
|
+
|
|
144
|
+
if ! agent_pod_path_ok "$folder_raw"; then
|
|
145
|
+
echo "devzone agent --pod : invalid folder path : ${folder_raw:-}" >&2
|
|
146
|
+
exit 1
|
|
147
|
+
fi
|
|
148
|
+
if [ ! -d "$folder_raw" ]; then
|
|
149
|
+
echo "devzone agent --pod : folder not found : $folder_raw" >&2
|
|
150
|
+
exit 1
|
|
151
|
+
fi
|
|
152
|
+
folder="$(cd "$folder_raw" && pwd -P)" || {
|
|
153
|
+
echo "devzone agent --pod : folder not found : $folder_raw" >&2
|
|
154
|
+
exit 1
|
|
155
|
+
}
|
|
156
|
+
if [ ! -r "${consigne_raw:-}" ]; then
|
|
157
|
+
echo "devzone agent --pod : consigne not found : ${consigne_raw:-}" >&2
|
|
158
|
+
exit 1
|
|
159
|
+
fi
|
|
160
|
+
consigne="$(cd "$(dirname "$consigne_raw")" && pwd -P)/$(basename "$consigne_raw")"
|
|
161
|
+
|
|
162
|
+
if ! agent_pod_validate_folder "$folder"; then
|
|
163
|
+
exit 1
|
|
164
|
+
fi
|
|
165
|
+
# The pod mounts this file read-only: refuse before any object is created.
|
|
166
|
+
if [ ! -f "$AGENT_POD_MODULES_FILE" ]; then
|
|
167
|
+
echo "devzone agent --pod : modules file missing : $AGENT_POD_MODULES_FILE (run devzone enable ia on the workspace)" >&2
|
|
168
|
+
exit 1
|
|
169
|
+
fi
|
|
170
|
+
|
|
171
|
+
# The log of the session stays in the agent state directory (shared with the pod).
|
|
172
|
+
etat="${AGENT_ETAT:-$HOME/.local/state/oc-lancer}"
|
|
173
|
+
mkdir -p "$etat"
|
|
174
|
+
journal_file="$etat/${AGENT_POD_SESSION_LABEL}.pod.log"
|
|
175
|
+
: >"$journal_file"
|
|
176
|
+
|
|
177
|
+
pod_name="$(agent_pod_name "$folder")"
|
|
178
|
+
AGENT_POD_ACTIVE_NAME="$pod_name"
|
|
179
|
+
agent_pod_set_trap
|
|
180
|
+
|
|
181
|
+
if ! agent_pod_create_configmap "$pod_name" "$consigne"; then
|
|
182
|
+
echo "devzone agent --pod : unable to create the configmap" >&2
|
|
183
|
+
exit 1
|
|
184
|
+
fi
|
|
185
|
+
|
|
186
|
+
manifest_file="$(agent_pod_build_manifest "$folder" "$consigne" "$pod_name")" || {
|
|
187
|
+
echo "devzone agent --pod : unable to build the manifest" >&2
|
|
188
|
+
exit 1
|
|
189
|
+
}
|
|
190
|
+
AGENT_POD_ACTIVE_MANIFEST="$manifest_file"
|
|
191
|
+
|
|
192
|
+
if ! agent_pod_create "$manifest_file"; then
|
|
193
|
+
echo "devzone agent --pod : unable to create the pod (kubectl create -f)" >&2
|
|
194
|
+
echo "devzone agent --pod : try again without --pod" >&2
|
|
195
|
+
exit 1
|
|
196
|
+
fi
|
|
197
|
+
|
|
198
|
+
phase="$(agent_pod_wait "$pod_name")" || rc=$?
|
|
199
|
+
agent_pod_fetch_logs "$pod_name" "$journal_file"
|
|
200
|
+
echo "=== end of agent session in pod (phase: ${phase:-Unknown})" >>"$journal_file"
|
|
201
|
+
agent_pod_show_tail "$journal_file"
|
|
202
|
+
|
|
203
|
+
if [ "$rc" -ne 0 ]; then
|
|
204
|
+
echo "devzone agent --pod : pod did not finish in time (phase: ${phase:-Unknown}) ; log : $journal_file" >&2
|
|
205
|
+
exit 1
|
|
206
|
+
fi
|
|
207
|
+
if [ "$phase" = "Failed" ]; then
|
|
208
|
+
echo "devzone agent --pod : session ended in failure ; log : $journal_file" >&2
|
|
209
|
+
exit 1
|
|
210
|
+
fi
|
|
211
|
+
echo "devzone agent --pod : session ended (phase: $phase) ; log : $journal_file" >&2
|
|
212
|
+
exit 0
|
|
213
|
+
}
|
package/.devcontainer/agent.sh
CHANGED
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env bash
|
|
2
|
-
# Dirige opencode sur une consigne : rotation
|
|
3
|
-
#
|
|
4
|
-
# reprise sur une session neuve, permissions sûres. Module ia (#221).
|
|
5
|
-
# devzone agent <dossier> <fichier-consigne>
|
|
6
|
-
# devzone agent etat
|
|
7
|
-
# devzone agent liberer [<modèle>|--tous]
|
|
8
|
-
# Au premier plan ; & ou nohup pour plusieurs sessions en parallèle, une par
|
|
9
|
-
# dossier (le journal et le rang des modèles sont partagés par instance).
|
|
2
|
+
# Dirige opencode sur une consigne : rotation, silence au depart, reprise.
|
|
3
|
+
# Module ia (#221). devzone agent <dossier> <consigne> | etat | liberer.
|
|
10
4
|
set -euo pipefail
|
|
11
5
|
# Dossier du script, liens symboliques suivis à la main : readlink -f n'existe
|
|
12
6
|
# pas sur macOS (tests sous bash 3.2).
|
|
@@ -22,25 +16,21 @@ done
|
|
|
22
16
|
ICI="$(cd -P "$(dirname "$SOURCE")" && pwd)"
|
|
23
17
|
# shellcheck disable=SC2034 # lue par agent-session.sh
|
|
24
18
|
RACINE="${DEVZONE_RACINE:-$(dirname "$ICI")}"
|
|
25
|
-
# Écarts de modèles et attente du réseau (#328)
|
|
26
19
|
# shellcheck source=agent-erreurs.sh disable=SC1091
|
|
27
20
|
. "$ICI/agent-erreurs.sh"
|
|
28
|
-
# Fichiers de droits des agents protégés (#361)
|
|
29
21
|
# shellcheck source=agent-droits.sh disable=SC1091
|
|
30
22
|
. "$ICI/agent-droits.sh"
|
|
31
|
-
# Configuration, rang partagé, journal et état (#328)
|
|
32
23
|
# shellcheck source=agent-session.sh disable=SC1091
|
|
33
24
|
. "$ICI/agent-session.sh"
|
|
34
|
-
# Workspace Kubernetes : projet et journal dans le pod (#431)
|
|
35
25
|
# shellcheck source=agent-workspace.sh disable=SC1091
|
|
36
26
|
. "$ICI/agent-workspace.sh"
|
|
37
|
-
# Modèle local en dernier de la rotation (#586)
|
|
38
27
|
# shellcheck source=agent-local.sh disable=SC1091
|
|
39
28
|
. "$ICI/agent-local.sh"
|
|
40
|
-
# Liste de secours si « opencode models opencode » ne répond pas : même ordre
|
|
41
|
-
# que la configuration opencode livrée par devzone.
|
|
42
29
|
FREE_MODELS=(big-pickle deepseek-v4.1-flash-free glm-5.3-flash-free nemotron-3.5-super-vl-free
|
|
43
30
|
nemotron-3.5-lightning-free mimo-v2.6-flash-free beam-free flint-40b-free nemotron-3-ultra-free)
|
|
31
|
+
# Session pod ephemere (#222)
|
|
32
|
+
# shellcheck source=agent-pod.sh disable=SC1091
|
|
33
|
+
. "$ICI/agent-pod.sh"
|
|
44
34
|
SILENCE="${DEVZONE_AGENT_SILENCE:-45}"
|
|
45
35
|
FIGEE="${DEVZONE_AGENT_FIGEE:-600}"
|
|
46
36
|
AGENT_ETAT="${DEVZONE_AGENT_ETAT:-$HOME/.local/state/oc-lancer}"
|
|
@@ -220,6 +210,7 @@ agent_lancer() {
|
|
|
220
210
|
exit 3
|
|
221
211
|
}
|
|
222
212
|
case "${1:-}" in
|
|
213
|
+
status) agent_pod_status ;;
|
|
223
214
|
etat) if [ "${2:-}" = "--json" ]; then exec bash "$ICI/agent-etat-json.sh"; else agent_etat; fi ;;
|
|
224
215
|
liberer)
|
|
225
216
|
[ -n "${2:-}" ] || { agent_aide >&2; exit 2; }
|
|
@@ -231,6 +222,14 @@ case "${1:-}" in
|
|
|
231
222
|
exit 2
|
|
232
223
|
;;
|
|
233
224
|
*)
|
|
225
|
+
if [ "${1:-}" = "--pod" ]; then
|
|
226
|
+
shift
|
|
227
|
+
if [ -z "${1:-}" ] || [ -z "${2:-}" ]; then
|
|
228
|
+
agent_aide >&2
|
|
229
|
+
exit 2
|
|
230
|
+
fi
|
|
231
|
+
agent_pod_lancer "$1" "$2"
|
|
232
|
+
fi
|
|
234
233
|
mode_local=0
|
|
235
234
|
if [ "${1:-}" = "--local" ]; then
|
|
236
235
|
mode_local=1
|
package/.devcontainer/devzone
CHANGED
|
@@ -52,7 +52,7 @@ fi
|
|
|
52
52
|
# change pas : deux montées simultanées (workflow versions) se fusionnent sans
|
|
53
53
|
# conflit, git n'en signalant qu'entre lignes voisines modifiées.
|
|
54
54
|
# Claude Code
|
|
55
|
-
IA_CLAUDE=@anthropic-ai/claude-code@2.1.
|
|
55
|
+
IA_CLAUDE=@anthropic-ai/claude-code@2.1.326
|
|
56
56
|
# opencode
|
|
57
57
|
IA_OPENCODE=opencode-ai@1.19.5
|
|
58
58
|
IA_PAQUETS=("$IA_CLAUDE" "$IA_OPENCODE")
|
package/README.md
CHANGED
|
@@ -236,6 +236,8 @@ La commande affiche la version du dossier et celle du paquet, et ne fait rien si
|
|
|
236
236
|
|
|
237
237
|
La mise à jour ne change jamais le mode du poste ; sur un poste Docker avec Kubernetes joignable, elle propose `devzone workspace migrate`.
|
|
238
238
|
|
|
239
|
+
Le workspace Kubernetes se met à jour à part : `devzone workspace update` le fait passer à la dernière release stable (ou `--version X.Y.Z`), image, charts et Argo CD au même tag. **Le pod `devzone-workspace-0` est recréé** : les fenêtres VS Code attachées au pod se coupent. L'image est vérifiée sur ghcr.io avant toute écriture, et rien ne change si elle n'existe pas encore. Détails dans la [référence](manage/docs/reference.md#mettre-à-jour-le-workspace).
|
|
240
|
+
|
|
239
241
|
Dans le conteneur, le récapitulatif `devzone` signale une version publiée plus récente (vérification npm au plus une fois par jour, sans bloquer hors ligne) : `○ devzone X.Y.Z disponible : sur le poste, devzone update`.
|
|
240
242
|
|
|
241
243
|
## Options
|
|
@@ -254,6 +256,8 @@ Dans le conteneur, le récapitulatif `devzone` signale une version publiée plus
|
|
|
254
256
|
|
|
255
257
|
**Module `argocd`** : Argo CD sur le cluster de devzone, interface sur https://127.0.0.1:8443 dans le conteneur (voir [Argo CD](manage/docs/reference.md#argo-cd)). Pour l'activer : `devzone enable argocd`.
|
|
256
258
|
|
|
259
|
+
**Option `devzone agent --pod`** : lance une session agent dans un pod éphémère isolé (ticket #222). Le pod est créé avec des ressources limitées (2 CPU, 4 Gi mémoire), des montages restreints du workspace et de l'état, et une affinité obligatoire vers le pod workspace. Isole : worktree du ticket au même chemin que dans le workspace, .git du dépôt, et sous-dossiers d'état (.config/opencode, .local/share/opencode, .local/state/oc-lancer, .local/npm en lecture seule). N'isole pas : le réseau (non filtré, c'est #220), le kubeconfig de l'hôte, `~/.config/gh`, `~/.claude`, les autres worktrees, et, comme le `.git` du dépôt est monté, les références git des autres branches y restent lisibles et modifiables. Sans `--pod`, le comportement `devzone agent` actuel est strictement inchangé.
|
|
260
|
+
|
|
257
261
|
Ces modules sont désactivés par défaut, activables à la demande depuis le conteneur (sans rebuild), et leur choix est conservé d'un démarrage à l'autre.
|
|
258
262
|
|
|
259
263
|
La commande `devzone` s'écrit en anglais, sous-commandes et options comprises (`enable`, `disable`, `platform`, `packages`, `update`, `uninstall`, `status`, `use` ; `postgres create`, `packages add`, `gitlab new-password`, `port --close`, `cluster --yes`). Les anciens noms français restent acceptés et écrivent un avertissement ; la table complète est dans [Anciens noms des commandes](manage/docs/reference.md#anciens-noms-des-commandes).
|
package/manage/devzone
CHANGED
|
@@ -432,7 +432,7 @@ devzone $(version) : environnement de développement conteneurisé
|
|
|
432
432
|
(sauvegarde les fichiers remplacés, propose make rebuild)
|
|
433
433
|
devzone uninstall dans un dossier devzone : retire conteneur, image, volumes
|
|
434
434
|
(à lancer avant npm uninstall -g devzone)
|
|
435
|
-
devzone workspace start|stop|status|shell
|
|
435
|
+
devzone workspace start|stop|status|shell|update
|
|
436
436
|
devzone workspace vscode|copy-to|copy-from|clone|migrate|revert|clean-docker
|
|
437
437
|
poste Kubernetes : pilote le chart devzone-workspace
|
|
438
438
|
devzone workspace services enable|disable <service>|status
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
#!/usr/bin/env bash
|
|
2
|
+
# devzone workspace update [--version X.Y.Z] [--yes] (#622): the workspace moves
|
|
3
|
+
# to the latest stable release, or to X.Y.Z: image, charts and Argo CD
|
|
4
|
+
# Application at that tag. Sourced by manage/workspace.sh, which defines
|
|
5
|
+
# IMAGE_REPO, kube_ready_reason, workspace_deploy, services_reconcile and the
|
|
6
|
+
# Argo CD helpers (argocd-workspace.sh, argocd-services.sh).
|
|
7
|
+
# update_workspace [--version X.Y.Z] [--yes]
|
|
8
|
+
# Nothing is written before the image of the release is seen on ghcr.io and
|
|
9
|
+
# the update is confirmed (--yes is required without a terminal). No gh, no
|
|
10
|
+
# Docker: git ls-remote for the tags, curl for the registry. The registry token
|
|
11
|
+
# is read into a variable and only sent in a request, never printed. bash 3.2
|
|
12
|
+
# (macOS).
|
|
13
|
+
|
|
14
|
+
# Latest stable release: tags vX.Y.Z only (no pre-release), in version order;
|
|
15
|
+
# prints its number without the v, nothing when none is found
|
|
16
|
+
update_latest_version() {
|
|
17
|
+
git ls-remote --tags --refs "$DEVZONE_REPO_URL" 2>/dev/null |
|
|
18
|
+
awk '$2 ~ /^refs\/tags\/v[0-9]+\.[0-9]+\.[0-9]+$/ { sub("refs/tags/v", "", $2); print $2 }' |
|
|
19
|
+
sort -V | tail -1
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
# The image of the release on ghcr.io: anonymous pull token, then the manifest
|
|
23
|
+
# headers. Status 0 when the image exists; a failing network counts as absent
|
|
24
|
+
update_image_exists() {
|
|
25
|
+
local repo_path="${IMAGE_REPO#ghcr.io/}" token
|
|
26
|
+
token="$(curl -fsS "https://ghcr.io/token?scope=repository:$repo_path:pull" 2>/dev/null |
|
|
27
|
+
sed -n 's/.*"token" *: *"\([^"]*\)".*/\1/p')" || token=""
|
|
28
|
+
[ -n "$token" ] || return 1
|
|
29
|
+
curl -fsSI -H "Authorization: Bearer $token" \
|
|
30
|
+
-H "Accept: application/vnd.oci.image.index.v1+json,application/vnd.docker.distribution.manifest.list.v2+json" \
|
|
31
|
+
"https://ghcr.io/v2/$repo_path/manifests/$1" >/dev/null 2>&1
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
# "<targetRevision> <image.tag>" of the Application devzone-workspace; empty
|
|
35
|
+
# when there is none (workspace installed with helm direct)
|
|
36
|
+
update_current() {
|
|
37
|
+
ak -n "$ARGOCD_NS" get application.argoproj.io "$WORKSPACE_APP" \
|
|
38
|
+
-o jsonpath='{.spec.source.targetRevision} {.spec.source.helm.parameters[?(@.name=="image.tag")].value}' 2>/dev/null || true
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
update_workspace() {
|
|
42
|
+
local version="" yes=no answer
|
|
43
|
+
while [ $# -gt 0 ]; do
|
|
44
|
+
case "$1" in
|
|
45
|
+
--version)
|
|
46
|
+
if [ $# -lt 2 ] || [ -z "$2" ]; then
|
|
47
|
+
echo "✖ option --version: give X.Y.Z (devzone workspace update [--version X.Y.Z] [--yes])" >&2
|
|
48
|
+
return 1
|
|
49
|
+
fi
|
|
50
|
+
version="$2"
|
|
51
|
+
shift 2
|
|
52
|
+
;;
|
|
53
|
+
--yes)
|
|
54
|
+
yes=yes
|
|
55
|
+
shift
|
|
56
|
+
;;
|
|
57
|
+
*)
|
|
58
|
+
echo "✖ unknown option: $1 (devzone workspace update [--version X.Y.Z] [--yes])" >&2
|
|
59
|
+
return 1
|
|
60
|
+
;;
|
|
61
|
+
esac
|
|
62
|
+
done
|
|
63
|
+
kube_ready_reason --hint >&2 || return 1
|
|
64
|
+
if [ -n "$version" ]; then
|
|
65
|
+
grep -Eq '^[0-9]+\.[0-9]+\.[0-9]+$' <<<"$version" || {
|
|
66
|
+
echo "✖ option --version: expected X.Y.Z, got: $version" >&2
|
|
67
|
+
return 1
|
|
68
|
+
}
|
|
69
|
+
else
|
|
70
|
+
version="$(update_latest_version || true)"
|
|
71
|
+
[ -n "$version" ] || {
|
|
72
|
+
echo "✖ no stable release found in $DEVZONE_REPO_URL (network, or no vX.Y.Z tag): nothing changed" >&2
|
|
73
|
+
return 1
|
|
74
|
+
}
|
|
75
|
+
fi
|
|
76
|
+
if ! update_image_exists "$version"; then
|
|
77
|
+
echo "✖ image $IMAGE_REPO:$version not found on ghcr.io (the release may still be publishing, or the network is down): nothing changed" >&2
|
|
78
|
+
return 1
|
|
79
|
+
fi
|
|
80
|
+
if [ "$(update_current)" = "v$version $version" ]; then
|
|
81
|
+
echo "✔ already up to date: v$version"
|
|
82
|
+
return 0
|
|
83
|
+
fi
|
|
84
|
+
echo "⚠ the workspace pod will be recreated: the VS Code windows attached to it will disconnect"
|
|
85
|
+
if [ "$yes" != yes ]; then
|
|
86
|
+
if [ ! -t 0 ]; then
|
|
87
|
+
echo "✖ no terminal to confirm: run again with --yes (devzone workspace update --yes)" >&2
|
|
88
|
+
return 1
|
|
89
|
+
fi
|
|
90
|
+
read -r -p "Update the workspace to v$version? [o/N] " answer || answer=""
|
|
91
|
+
case "$answer" in
|
|
92
|
+
o | O | oui | y | Y | yes) ;;
|
|
93
|
+
*)
|
|
94
|
+
echo "✖ canceled, nothing changed" >&2
|
|
95
|
+
return 1
|
|
96
|
+
;;
|
|
97
|
+
esac
|
|
98
|
+
fi
|
|
99
|
+
# Same path as workspace start, at the release: Argo CD revision and image tag
|
|
100
|
+
export DEVZONE_ARGOCD_REVISION="v$version"
|
|
101
|
+
workspace_deploy "$IMAGE_REPO" "$version" ""
|
|
102
|
+
if argocd_holds_charts; then
|
|
103
|
+
services_reconcile || return 1
|
|
104
|
+
fi
|
|
105
|
+
echo "✔ workspace on v$version; follow the rollout: devzone workspace status"
|
|
106
|
+
}
|
package/manage/workspace.sh
CHANGED
|
@@ -95,11 +95,8 @@ start_workspace() {
|
|
|
95
95
|
workspace_helm_deploy() {
|
|
96
96
|
local repo="$1" tag="$2" with_image="$3" args=()
|
|
97
97
|
args=(--namespace devzone-workspace --create-namespace)
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
else
|
|
101
|
-
args+=(--set "image.tag=$tag")
|
|
102
|
-
fi
|
|
98
|
+
[ -z "$with_image" ] || args+=(--set "image.repository=$repo")
|
|
99
|
+
args+=(--set "image.tag=$tag")
|
|
103
100
|
# latest moves at every release: an image already on the node would stay
|
|
104
101
|
# the old one with IfNotPresent (#515)
|
|
105
102
|
if [ "$tag" = latest ]; then
|
|
@@ -118,8 +115,7 @@ stop_workspace() {
|
|
|
118
115
|
# Opens a shell in the workspace container.
|
|
119
116
|
shell_workspace() {
|
|
120
117
|
# shellcheck disable=SC2046
|
|
121
|
-
kubectl $(kubectl_flag) exec -it devzone-workspace-0
|
|
122
|
-
--namespace devzone-workspace -c workspace -- bash
|
|
118
|
+
kubectl $(kubectl_flag) exec -it devzone-workspace-0 --namespace devzone-workspace -c workspace -- bash
|
|
123
119
|
}
|
|
124
120
|
|
|
125
121
|
# VS Code steps (#399): attach to the pod with Kubernetes and Dev Containers
|
|
@@ -193,6 +189,8 @@ copy_from() {
|
|
|
193
189
|
. "$HERE/scripts/argocd-workspace.sh"
|
|
194
190
|
# shellcheck source=manage/scripts/argocd-services.sh
|
|
195
191
|
. "$HERE/scripts/argocd-services.sh"
|
|
192
|
+
# shellcheck source=manage/scripts/workspace-update.sh
|
|
193
|
+
. "$HERE/scripts/workspace-update.sh"
|
|
196
194
|
|
|
197
195
|
# English command names are accepted, French ones unchanged and warned (#502,
|
|
198
196
|
# #532). A copied devzone may miss the aliases file: then no normalization.
|
|
@@ -217,6 +215,7 @@ fi
|
|
|
217
215
|
|
|
218
216
|
case "${1:-}" in
|
|
219
217
|
start) start_workspace "${@:2}" ;;
|
|
218
|
+
update) update_workspace "${@:2}" ;;
|
|
220
219
|
stop) stop_workspace ;;
|
|
221
220
|
status) status_workspace ;;
|
|
222
221
|
shell) shell_workspace ;;
|
|
@@ -231,8 +230,9 @@ case "${1:-}" in
|
|
|
231
230
|
services) services "${@:2}" ;;
|
|
232
231
|
argocd) argocd_cmd "${@:2}" ;;
|
|
233
232
|
'' | -h | --help | aide)
|
|
234
|
-
echo "devzone workspace start|stop|status|shell|vscode|copy-to|copy-from|clone|ports|services|argocd|migrate|revert|clean-docker"
|
|
233
|
+
echo "devzone workspace start|stop|status|shell|vscode|copy-to|copy-from|clone|ports|services|argocd|migrate|revert|clean-docker|update"
|
|
235
234
|
echo " start [--image repository:tag] install workspace (image for devzone version by default)"
|
|
235
|
+
echo " update [--version X.Y.Z] [--yes] move to the latest stable release (or X.Y.Z); the pod is recreated"
|
|
236
236
|
echo " clone <url> [<name>] git clone into the pod projects folder (gh credentials, identity, repowarden hooks)"
|
|
237
237
|
echo " ports [start|stop|status] applications and services from pod on workstation localhost"
|
|
238
238
|
echo " services enable|disable <service> [options] | status"
|
|
@@ -244,7 +244,7 @@ case "${1:-}" in
|
|
|
244
244
|
echo " clean-docker remove devzone-* Docker volumes, after confirmation [y/N] (--yes)"
|
|
245
245
|
;;
|
|
246
246
|
*)
|
|
247
|
-
echo "✖ unknown subcommand: $1 (devzone workspace start|stop|status|shell|vscode|copy-to|copy-from|clone|ports|services|argocd|migrate|revert|clean-docker)" >&2
|
|
247
|
+
echo "✖ unknown subcommand: $1 (devzone workspace start|stop|status|shell|vscode|copy-to|copy-from|clone|ports|services|argocd|migrate|revert|clean-docker|update)" >&2
|
|
248
248
|
exit 1
|
|
249
249
|
;;
|
|
250
250
|
esac
|