devzone 0.48.0 → 0.48.2
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/argocd/gitops.sh +6 -1
- package/.devcontainer/argocd/services.sh +23 -5
- package/README.md +2 -0
- package/manage/devzone +1 -1
- package/manage/scripts/argocd-services-svc.sh +2 -2
- 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
|
@@ -127,8 +127,13 @@ GitOps repository of devzone, written by the devzone commands (never by hand): t
|
|
|
127
127
|
gitops_blob() { git hash-object "$1" 2>/dev/null || true; }
|
|
128
128
|
|
|
129
129
|
gitops_sha() {
|
|
130
|
+
local out
|
|
130
131
|
if gitops_is_gitlab; then gitlab_gitops_sha "$@"; return; fi
|
|
131
|
-
|
|
132
|
+
# A missing file answers 404 with its error body on stdout: never taken
|
|
133
|
+
# for a sha, or a removal would DELETE what is not there (#625)
|
|
134
|
+
out="$(gh api "repos/$(gitops_slug)/contents/$1" --jq .sha 2>/dev/null)" || out=""
|
|
135
|
+
case "$out" in '' | *[!0-9a-f]*) out="" ;; esac
|
|
136
|
+
printf '%s' "$out"
|
|
132
137
|
}
|
|
133
138
|
|
|
134
139
|
# Writes <file> at <path> of the repository (create or update), <message>
|
|
@@ -125,7 +125,8 @@ services_application_delete() {
|
|
|
125
125
|
|
|
126
126
|
# Every service of the list applied or released: on → namespace, secret and
|
|
127
127
|
# Application; off → Application removed (namespace and volumes kept); not
|
|
128
|
-
# declared: untouched. One failing service does not stop the others
|
|
128
|
+
# declared: untouched. One failing service does not stop the others; a step
|
|
129
|
+
# prints its ✔ only when it succeeded and its ✖ names the service and the step
|
|
129
130
|
services_reconcile() {
|
|
130
131
|
local svc state code=0
|
|
131
132
|
for svc in $SERVICES_LIST; do
|
|
@@ -134,18 +135,35 @@ services_reconcile() {
|
|
|
134
135
|
on)
|
|
135
136
|
# Before the namespace and the secret: a misnamed chart applies nothing
|
|
136
137
|
chart_require "$svc" || { code=2; continue; }
|
|
137
|
-
services_namespace_prepare "$svc" ||
|
|
138
|
+
services_namespace_prepare "$svc" || {
|
|
139
|
+
echo "✖ $svc: namespace step failed" >&2
|
|
140
|
+
code=1
|
|
141
|
+
continue
|
|
142
|
+
}
|
|
138
143
|
if command -v "services_secret_$svc" >/dev/null 2>&1; then
|
|
139
|
-
"services_secret_$svc" ||
|
|
144
|
+
"services_secret_$svc" || {
|
|
145
|
+
echo "✖ $svc: secret step failed" >&2
|
|
146
|
+
code=1
|
|
147
|
+
continue
|
|
148
|
+
}
|
|
140
149
|
else
|
|
141
150
|
echo "✖ no secret hook for $svc (services_secret_$svc): the sync will fail" >&2
|
|
142
151
|
code=1
|
|
152
|
+
continue
|
|
143
153
|
fi
|
|
144
|
-
services_application_apply "$svc" ||
|
|
154
|
+
services_application_apply "$svc" || {
|
|
155
|
+
echo "✖ $svc: declare step failed" >&2
|
|
156
|
+
code=1
|
|
157
|
+
continue
|
|
158
|
+
}
|
|
145
159
|
echo "✔ Application $(services_app_of "$svc") declared (chart charts/devzone-$svc)"
|
|
146
160
|
;;
|
|
147
161
|
off)
|
|
148
|
-
services_application_delete "$svc" ||
|
|
162
|
+
services_application_delete "$svc" || {
|
|
163
|
+
echo "✖ $svc: remove step failed" >&2
|
|
164
|
+
code=1
|
|
165
|
+
continue
|
|
166
|
+
}
|
|
149
167
|
echo "✔ Application $(services_app_of "$svc") removed (namespace and volumes kept)"
|
|
150
168
|
;;
|
|
151
169
|
esac
|
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
|
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
|
|
@@ -85,13 +85,13 @@ services_argocd_toggle() {
|
|
|
85
85
|
chart_require "$svc" || return $?
|
|
86
86
|
echo "▶ $svc as an Argo CD Application (charts/devzone-$svc at $(argocd_revision))…"
|
|
87
87
|
services_note "$svc" on
|
|
88
|
-
services_reconcile
|
|
88
|
+
services_reconcile || return $?
|
|
89
89
|
echo "✔ Application devzone-$svc declared ([services] $svc = on in $ARGOCD_CONF); status: devzone workspace argocd status; local access: devzone workspace ports"
|
|
90
90
|
;;
|
|
91
91
|
disable)
|
|
92
92
|
yes="$(yes_flag "services disable $svc [--yes]" "$@")" || return 1
|
|
93
93
|
services_note "$svc" off
|
|
94
|
-
services_reconcile
|
|
94
|
+
services_reconcile || return $?
|
|
95
95
|
if [ "$yes" = 1 ]; then
|
|
96
96
|
ak delete namespace "devzone-$svc" --wait=true --ignore-not-found >/dev/null
|
|
97
97
|
case "$svc" in
|
|
@@ -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
|