devzone 7.0.1 → 7.0.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.
@@ -20,6 +20,19 @@ while [ -L "$SOURCE" ]; do
20
20
  esac
21
21
  done
22
22
  ICI="$(cd -P "$(dirname "$SOURCE")" && pwd)"
23
+ # Go first (#754): a command ported to Go runs in the devzone-pod binary of the image.
24
+ # DEVZONE_NO_GO=1 forces the shell, DEVZONE_FROM_GO=1 avoids loops.
25
+ if [ -z "${DEVZONE_NO_GO:-}" ] && [ -z "${DEVZONE_FROM_GO:-}" ]; then
26
+ case "$(uname -m)" in
27
+ x86_64) POD_GO_ARCH=amd64 ;;
28
+ aarch64 | arm64) POD_GO_ARCH=arm64 ;;
29
+ *) POD_GO_ARCH="" ;;
30
+ esac
31
+ POD_GO="$ICI/bin/devzone-pod-linux-$POD_GO_ARCH"
32
+ if [ -n "$POD_GO_ARCH" ] && [ -x "$POD_GO" ] && "$POD_GO" handles "${1:-}" >/dev/null 2>&1; then
33
+ exec "$POD_GO" "$@"
34
+ fi
35
+ fi
23
36
  # shellcheck source=SCRIPTDIR/help.sh
24
37
  # shellcheck disable=SC1091
25
38
  . "$ICI/help.sh"
@@ -64,7 +77,7 @@ fi
64
77
  # two simultaneous bumps (versions workflow) merge without conflict, git only
65
78
  # reporting neighbouring lines changed.
66
79
  # Claude Code
67
- IA_CLAUDE=@anthropic-ai/claude-code@2.1.330
80
+ IA_CLAUDE=@anthropic-ai/claude-code@2.1.332
68
81
  # opencode
69
82
  IA_OPENCODE=opencode-ai@1.19.6
70
83
  IA_PAQUETS=("$IA_CLAUDE" "$IA_OPENCODE")
@@ -179,7 +192,6 @@ case "${1:-}" in
179
192
  ;;
180
193
  esac
181
194
  ;;
182
- ticket) bash "$ICI/ticket.sh" "${@:2}" ;;
183
195
  build)
184
196
  bash "$ICI/workspace-build.sh" "${@:2}"
185
197
  ;;
@@ -202,7 +214,6 @@ case "${1:-}" in
202
214
  bash "$ICI/password.sh" chemin
203
215
  ;;
204
216
  -h | --help | help) devzone_aide ;;
205
- -v | --version) echo "devzone ${DEVZONE_VERSION:-unknown}" ;;
206
217
  test-bash32) bash "$RACINE/manage/test/bash32.sh" ;;
207
218
  test-gitlab) DEVZONE_STATE="$ETAT" bash "$ICI/gitlab/test-gitlab.sh" "${@:2}" ;;
208
219
  platform)
@@ -98,6 +98,14 @@ show_state() {
98
98
  if [ -n "$current_cluster" ] && ! cluster_is_local "$current_cluster"; then
99
99
  printf ' ⚠ cluster remote: %s — services on a remote cluster\n' "$current_cluster"
100
100
  fi
101
+ # Limited account token (#845): renewed as soon as it is close to expiry,
102
+ # only outside the pod and with a services cluster chosen (the cases where
103
+ # kube-account.sh is used); a failed renewal is reported for devzone repair
104
+ if ! in_pod && [ -n "$current_cluster" ] && ! account_token_fresh; then
105
+ if ! bash "$ICI/kube-account.sh" jeton >/dev/null 2>&1; then
106
+ echo " ⚠ limited account token expired: devzone repair"
107
+ fi
108
+ fi
101
109
  # Old kind-gitlab cluster still present: invite to migrate (#396)
102
110
  if kind get clusters 2>/dev/null | grep -qx "gitlab${INSTANCE_SUFFIX}"; then
103
111
  printf ' ⚠ old kind-gitlab cluster%s: devzone gitlab migrate\n' "$INSTANCE_SUFFIX"
@@ -3,10 +3,10 @@
3
3
  # agents) can only act in the devzone-* namespaces. The account is the
4
4
  # ServiceAccount devzone-agent of the devzone-system namespace, bound to the
5
5
  # edit ClusterRole (no RBAC, no quotas) in each devzone namespace by a
6
- # RoleBinding, with a 24 h TokenRequest token renewed at startup (startup.sh) and
7
- # by « devzone repair ». The installers alone use the admin context (host context
8
- # in ~/.kube/hote.config, kind cluster in ~/.kube/config); shells and agents only
9
- # have ~/.kube/config.
6
+ # RoleBinding, with a 24 h TokenRequest token renewed at startup (startup.sh),
7
+ # by « devzone repair » and by the summary before expiry. The installers alone
8
+ # use the admin context (host context in ~/.kube/hote.config, kind cluster in
9
+ # ~/.kube/config); shells and agents only have ~/.kube/config.
10
10
  # Library sourced by cluster.sh; executable for the token:
11
11
  # kube-account.sh jeton (argument kept: called by startup.sh and devzone repair)
12
12
 
@@ -14,6 +14,7 @@ ACCOUNT_NS=devzone-system
14
14
  ACCOUNT_SA=devzone-agent
15
15
  ACCOUNT_DURATION=24h
16
16
  ACCOUNT_CONFIG="${DEVZONE_KUBE_CONFIG:-$HOME/.kube/config}"
17
+ ACCOUNT_TOKEN_EXPIRY="${DEVZONE_KUBE_TOKEN_EXPIRY:-$HOME/.kube/devzone-token.expiry}"
17
18
 
18
19
  # kubeconfig file that holds the admin context ctx: hote.config if it lists it
19
20
  # (host clusters), otherwise ~/.kube/config (kind clusters of the container).
@@ -129,16 +130,49 @@ account_catch_up() {
129
130
  done < <(account_admin "$ctx" get namespaces -l "$label" -o name 2>/dev/null || true)
130
131
  }
131
132
 
133
+ # Epoch seconds of the RFC 3339 expiration timestamp of a TokenRequest
134
+ # response; empty when the local date cannot read it, so the caller falls back
135
+ # to now + 24 h (Bash 3.2: GNU date -d, then the BSD date form).
136
+ account_expiry_epoch() {
137
+ local ts="$1" epoch
138
+ [ -n "$ts" ] || return 0
139
+ epoch="$(date -u -d "$ts" +%s 2>/dev/null || true)"
140
+ if [ -n "$epoch" ]; then
141
+ echo "$epoch"
142
+ return 0
143
+ fi
144
+ epoch="$(date -j -u -f '%Y-%m-%dT%H:%M:%SZ' "$ts" +%s 2>/dev/null || true)"
145
+ [ -n "$epoch" ] && echo "$epoch"
146
+ }
147
+
148
+ # True when the token has more than one hour left, read from the expiry file
149
+ # without any cluster call: absent, unreadable, non-numeric, close or past
150
+ # expiry → false.
151
+ account_token_fresh() {
152
+ local expiry now
153
+ [ -f "$ACCOUNT_TOKEN_EXPIRY" ] || return 1
154
+ expiry="$(cat "$ACCOUNT_TOKEN_EXPIRY" 2>/dev/null || true)"
155
+ case "$expiry" in
156
+ '' | *[!0-9]*) return 1 ;;
157
+ esac
158
+ now="$(date +%s)"
159
+ [ "$expiry" -gt $((now + 3600)) ]
160
+ }
161
+
132
162
  # Renews the account's token (24 h TokenRequest) and writes it into the devzone
133
163
  # context of ~/.kube/config: user devzone-agent, same cluster as the admin
134
164
  # context (cluster entry copied: server, certificate authority and
135
- # tls-server-name of the host context).
165
+ # tls-server-name of the host context). The expiry timestamp of the TokenRequest
166
+ # response is kept in ACCOUNT_TOKEN_EXPIRY (now + 24 h if it is unreadable).
136
167
  account_token() {
137
- local ctx="$1" conf token cluster server tls ca_data ca_file
168
+ local ctx="$1" conf token cluster server tls ca_data ca_file out expires expiry now
138
169
  local entry=()
139
170
  conf="$(account_admin_config "$ctx")"
140
- token="$(account_admin "$ctx" create token "$ACCOUNT_SA" -n "$ACCOUNT_NS" \
141
- --duration="$ACCOUNT_DURATION")" || return 1
171
+ out="$(account_admin "$ctx" create token "$ACCOUNT_SA" -n "$ACCOUNT_NS" \
172
+ --duration="$ACCOUNT_DURATION" \
173
+ -o jsonpath='{.status.token}{"\n"}{.status.expirationTimestamp}')" || return 1
174
+ token="$(printf '%s\n' "$out" | sed -n '1p')"
175
+ expires="$(printf '%s\n' "$out" | sed -n '2p')"
142
176
  if [ -z "$token" ]; then
143
177
  echo "devzone : limited account token is empty" >&2
144
178
  return 1
@@ -175,7 +209,13 @@ account_token() {
175
209
  KUBECONFIG="$ACCOUNT_CONFIG" kubectl config set-credentials "$ACCOUNT_SA" \
176
210
  --token="$token" >/dev/null
177
211
  KUBECONFIG="$ACCOUNT_CONFIG" kubectl config set-context devzone \
178
- --cluster="$cluster" --user="$ACCOUNT_SA" >/dev/null
212
+ --cluster="$cluster" --user="$ACCOUNT_SA" >/dev/null || return 1
213
+ now="$(date +%s)"
214
+ expiry="$(account_expiry_epoch "$expires")"
215
+ [ -n "$expiry" ] || expiry=$((now + 86400))
216
+ mkdir -p "$(dirname "$ACCOUNT_TOKEN_EXPIRY")"
217
+ printf '%s\n' "$expiry" >"$ACCOUNT_TOKEN_EXPIRY"
218
+ chmod 600 "$ACCOUNT_TOKEN_EXPIRY"
179
219
  }
180
220
 
181
221
  # Direct execution: account token renewed at startup (startup.sh) and by
@@ -190,6 +190,15 @@ state_json() {
190
190
  clusters_command="devzone use $host_ctx"
191
191
  fi
192
192
 
193
+ # Limited account token (#845): renewed as soon as it is close to expiry,
194
+ # only outside the pod and with a services cluster chosen; a failed renewal
195
+ # becomes an alert with the repair command.
196
+ if ! in_pod && [ -n "$services_cluster" ] && ! account_token_fresh; then
197
+ if ! bash "$ICI/kube-account.sh" jeton >/dev/null 2>&1; then
198
+ append_alert limited_account_token "limited account token expired" "devzone repair"
199
+ fi
200
+ fi
201
+
193
202
  if ports_out="$(bash "$ICI/ports.sh" list --json 2>/dev/null)"; then
194
203
  if printf '%s' "$ports_out" | jq -e . >/dev/null 2>&1; then
195
204
  ports_json="$ports_out"
package/bin/SHA256SUMS CHANGED
@@ -1,6 +1,6 @@
1
- 2ab9c34ed8ad25d22a2beaf877a1171daf432f7157ea76d2b863310d59d82264 devzone-linux-amd64
2
- ae932a2a06b5ca20017e96dc54b253d687f108c791f52f33372249aba20dfc66 devzone-linux-arm64
3
- d672671ed82977af87e9dce17cf602d91f6971e912dabfaa7a664982c7341344 devzone-darwin-amd64
4
- b0d97bae3413cf8f2364f9df1fc80eb0a7d41c37201c01453a83391bb460354c devzone-darwin-arm64
5
- 848a91cdd8cce2ca06c4470b588675587293b721870a0992da8f07f2f71f5423 devzone-windows-amd64.exe
6
- e0043389aef4177431b9cacd68faa452662a7004b27c57b3b52a822b73e2a256 devzone-windows-arm64.exe
1
+ dae2956fa9a2975b9295c6f1d5e24ac6c772c2d9cd1f5e63bb581d7c7bdf0495 devzone-linux-amd64
2
+ a4bab424148b4aa019e51ed859e439dd03be1ebd43d03adc99879c69e8575e66 devzone-linux-arm64
3
+ d8876e58859e18cf93bf3e97536c53d7cebfc6038175cd56a0a6222be83d6e47 devzone-darwin-amd64
4
+ f33bfbfa7e8e21a65e94c9f3ac07a7f55ccfa2f99b080fb2b6385b1942f86886 devzone-darwin-arm64
5
+ bf2edc599d52a290a942fdf14ca56e04c19b94f18f916fa1b26a4e7342226005 devzone-windows-amd64.exe
6
+ b21d0014a75782033e8faece7bbc6fe0b980e103f53be91a935d0930fe287efc devzone-windows-arm64.exe
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -128,7 +128,7 @@ workspace_undeploy() {
128
128
  argocd_delete_application "$WORKSPACE_APP"
129
129
  else
130
130
  # shellcheck disable=SC2046
131
- helm $(drapeau_helm) uninstall devzone-workspace --namespace devzone-workspace
131
+ helm $(helm_flag) uninstall devzone-workspace --namespace devzone-workspace
132
132
  fi
133
133
  }
134
134
 
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # Argo CD of the Kubernetes workspace, driven from the workstation (#516).
3
- # Sourced by manage/workspace.sh (drapeau_kubectl, drapeau_helm, RACINE: the
3
+ # Sourced by manage/workspace.sh (kubectl_flag, helm_flag, RACINE: the
4
4
  # package; $PWD: the devzone folder of the workstation, its .devzone.modules,
5
5
  # workspace/.argocd and .password).
6
6
  # argocd_wanted 0 unless .devzone.modules says argocd=off (on by default)
@@ -29,7 +29,7 @@ argocd_secrets_dir() { printf '%s/workspace/.argocd' "$PWD"; }
29
29
  # kubectl of the workstation, context devzone when it exists
30
30
  ak() {
31
31
  # shellcheck disable=SC2046
32
- kubectl $(drapeau_kubectl) "$@"
32
+ kubectl $(kubectl_flag) "$@"
33
33
  }
34
34
 
35
35
  # Last value of a key of .devzone.modules of the workstation (empty if none)
@@ -146,7 +146,7 @@ argocd_install() {
146
146
  # first, then installed from the local chart (#538)
147
147
  helm dependency build "$(argocd_chart)" >/dev/null
148
148
  # shellcheck disable=SC2046
149
- helm $(drapeau_helm) upgrade --install argocd "$(argocd_chart)" \
149
+ helm $(helm_flag) upgrade --install argocd "$(argocd_chart)" \
150
150
  --namespace "$ARGOCD_NS" \
151
151
  --timeout "${ARGOCD_WAIT}s" --wait || return 1
152
152
  argocd_save_admin_password
@@ -179,7 +179,7 @@ argocd_uninstall() {
179
179
  gitops_direct_delete_application "${app#*/}" keep
180
180
  done <<<"$(ak -n "$ARGOCD_NS" get applications.argoproj.io -o name 2>/dev/null || true)"
181
181
  # shellcheck disable=SC2046
182
- helm $(drapeau_helm) uninstall argocd --namespace "$ARGOCD_NS" >/dev/null 2>&1 || true
182
+ helm $(helm_flag) uninstall argocd --namespace "$ARGOCD_NS" >/dev/null 2>&1 || true
183
183
  ak delete namespace "$ARGOCD_NS" --wait=true --ignore-not-found >/dev/null
184
184
  fi
185
185
  rm -rf "$(argocd_secrets_dir)"
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env bash
2
2
  # devzone workspace services (#528): installs or removes the devzone services
3
3
  # (gitlab, postgres, mysql, argocd) of a Kubernetes workspace from the workstation.
4
- # Sourced by manage/workspace.sh (drapeau_kubectl, POD, NAMESPACE).
4
+ # Sourced by manage/workspace.sh (kubectl_flag, POD, NAMESPACE).
5
5
  # devzone workspace services enable <service> [options]
6
6
  # devzone workspace services disable <service> [--yes]
7
7
  # devzone workspace services status
@@ -53,7 +53,7 @@ services_namespace() {
53
53
  services_pod_running() {
54
54
  local phase
55
55
  # shellcheck disable=SC2046
56
- phase="$(kubectl $(drapeau_kubectl) get pod "$POD" --namespace "$NAMESPACE" \
56
+ phase="$(kubectl $(kubectl_flag) get pod "$POD" --namespace "$NAMESPACE" \
57
57
  -o jsonpath='{.status.phase}' 2>/dev/null)" || phase=""
58
58
  [ "$phase" = Running ]
59
59
  }
@@ -62,7 +62,7 @@ services_pod_running() {
62
62
  # cluster-admin (idempotent apply)
63
63
  services_admin_create() {
64
64
  # shellcheck disable=SC2046
65
- kubectl $(drapeau_kubectl) apply -f - >/dev/null <<EOF
65
+ kubectl $(kubectl_flag) apply -f - >/dev/null <<EOF
66
66
  apiVersion: v1
67
67
  kind: ServiceAccount
68
68
  metadata:
@@ -86,10 +86,10 @@ EOF
86
86
 
87
87
  services_admin_delete() {
88
88
  # shellcheck disable=SC2046
89
- kubectl $(drapeau_kubectl) delete clusterrolebinding "$SERVICES_ADMIN_SA" \
89
+ kubectl $(kubectl_flag) delete clusterrolebinding "$SERVICES_ADMIN_SA" \
90
90
  --ignore-not-found >/dev/null 2>&1 || true
91
91
  # shellcheck disable=SC2046
92
- kubectl $(drapeau_kubectl) delete serviceaccount "$SERVICES_ADMIN_SA" \
92
+ kubectl $(kubectl_flag) delete serviceaccount "$SERVICES_ADMIN_SA" \
93
93
  --namespace "$NAMESPACE" --ignore-not-found >/dev/null 2>&1 || true
94
94
  }
95
95
 
@@ -134,7 +134,7 @@ services_run() {
134
134
  fi
135
135
  trap services_admin_delete EXIT
136
136
  # shellcheck disable=SC2046
137
- if ! token="$(kubectl $(drapeau_kubectl) create token "$SERVICES_ADMIN_SA" \
137
+ if ! token="$(kubectl $(kubectl_flag) create token "$SERVICES_ADMIN_SA" \
138
138
  --namespace "$NAMESPACE" --duration "$SERVICES_TOKEN_DURATION")" || [ -z "$token" ]; then
139
139
  echo "✖ cannot get a token of the temporary administrator (kubectl 1.24 or more)" >&2
140
140
  services_admin_delete
@@ -144,7 +144,7 @@ services_run() {
144
144
  echo "▶ $action $service in the pod ${POD}…"
145
145
  # The installer of the pod takes --yes (#557) : no translation, no warning
146
146
  # shellcheck disable=SC2046
147
- printf '%s\n' "$token" | kubectl $(drapeau_kubectl) exec -i "$POD" --namespace "$NAMESPACE" \
147
+ printf '%s\n' "$token" | kubectl $(kubectl_flag) exec -i "$POD" --namespace "$NAMESPACE" \
148
148
  -c workspace -- bash "$SERVICES_ADMIN_SCRIPT" "$action" "$service" "$@" || code=$?
149
149
  services_admin_delete
150
150
  trap - EXIT
@@ -162,7 +162,7 @@ services_status() {
162
162
  for s in gitlab postgres mysql argocd; do
163
163
  ns="$(services_namespace "$s")"
164
164
  # shellcheck disable=SC2046
165
- if kubectl $(drapeau_kubectl) get namespace "$ns" >/dev/null 2>&1; then
165
+ if kubectl $(kubectl_flag) get namespace "$ns" >/dev/null 2>&1; then
166
166
  echo " ✔ $s installed (namespace $ns): devzone workspace services disable $s"
167
167
  else
168
168
  echo " ○ $s not installed: devzone workspace services enable $s"
@@ -1,69 +1,4 @@
1
1
  #!/usr/bin/env bash
2
- # Working clones inside the pod (#558), sourced by manage/workspace.sh:
3
- # devzone workspace clone <url> [<name>]
4
- # git clone into $PROJECTS_DIR/<name> of the pod over HTTPS, credentials given
5
- # by the gh git credential helper set up in the pod, git identity copied from
6
- # the workstation, then "repowarden install" in the clone (hooks). bash 3.2.
7
-
8
- # Script run in the pod: $1 clone folder, $2 url, $3 git name, $4 git email.
9
- # Exit 3: the folder exists and is not a clone of this url.
10
- workspace_clone_pod_script() {
11
- cat <<'POD'
12
- set -eu
13
- dir="$1" url="$2" name="$3" email="$4"
14
- norm() { local u="${1%/}"; echo "${u%.git}"; }
15
- gh auth setup-git
16
- if [ -d "$dir/.git" ]; then
17
- remote="$(git -C "$dir" remote get-url origin 2>/dev/null || true)"
18
- if [ "$(norm "$remote")" != "$(norm "$url")" ]; then
19
- echo "✖ $dir already exists with another remote: ${remote:-none}" >&2
20
- exit 3
21
- fi
22
- echo "$dir is already a clone of $url"
23
- elif [ -e "$dir" ] && [ -n "$(ls -A "$dir" 2>/dev/null)" ]; then
24
- echo "✖ $dir already exists and is not a git clone" >&2
25
- exit 3
26
- else
27
- git clone "$url" "$dir"
28
- fi
29
- [ -z "$name" ] || git -C "$dir" config user.name "$name"
30
- [ -z "$email" ] || git -C "$dir" config user.email "$email"
31
- if command -v repowarden >/dev/null 2>&1; then
32
- (cd "$dir" && repowarden install)
33
- else
34
- echo "⚠ repowarden missing in the pod: hooks not installed in $dir" >&2
35
- fi
36
- POD
37
- }
38
-
39
- # Folder name from a url: last path segment without .git.
40
- workspace_clone_name() {
41
- local u="${1%/}"
42
- u="${u##*/}"
43
- u="${u##*:}"
44
- echo "${u%.git}"
45
- }
46
-
47
- workspace_clone() {
48
- local url="${1:-}" name="${2:-}" git_name git_email
49
- if [ -z "$url" ] || [ $# -gt 2 ]; then
50
- echo "✖ usage: devzone workspace clone <url> [<name>]" >&2
51
- return 1
52
- fi
53
- [ -n "$name" ] || name="$(workspace_clone_name "$url")"
54
- case "$name" in
55
- '' | . | .. | -* | */* | *[!A-Za-z0-9._-]*)
56
- echo "✖ invalid folder name: ${name:-empty} (letters, digits, . _ - only)" >&2
57
- return 1
58
- ;;
59
- esac
60
- git_name="$(git config --get user.name 2>/dev/null || true)"
61
- git_email="$(git config --get user.email 2>/dev/null || true)"
62
- # shellcheck disable=SC2046
63
- workspace_clone_pod_script | kubectl $(kubectl_flag) exec -i "$POD" \
64
- --namespace "$NAMESPACE" -c workspace -- \
65
- bash -s -- "$PROJECTS_DIR/$name" "$url" "$git_name" "$git_email"
66
- }
67
2
 
68
3
  # Guard of the agents in the pod (#558): when the ai module is on there,
69
4
  # "repowarden agents init --global" is run (idempotent), so that an agent
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env bash
2
2
  # Stale copies in the pod (#558), sourced by manage/workspace.sh:
3
3
  # status_workspace pod status, then the legacy copies still in the pod
4
- # copy_guard copy-to never overwrites a pod clone of another remote
5
4
  # Uses kubectl_flag, POD, NAMESPACE and PROJECTS_DIR from workspace.sh.
6
5
 
7
6
  # Shows workspace pod status, then the legacy copies still in the pod.
@@ -43,32 +42,3 @@ workspace_legacy_copies() {
43
42
  echo " 2. remove them from the pod shell (devzone workspace shell), one folder at a time:"
44
43
  for d in $found; do echo " rm -rf $PROJECTS_DIR/$d"; done
45
44
  }
46
-
47
- # Script run in the pod: $1 pod folder, $2 remote of the workstation folder.
48
- # Exit 3 (remote printed) when the pod folder is a clone of another remote.
49
- workspace_copy_pod_script() {
50
- cat <<'POD'
51
- [ -e "$1/.git" ] || exit 0
52
- r="$(git -C "$1" remote get-url origin 2>/dev/null || true)"
53
- n() { local u="${1%/}"; echo "${u%.git}"; }
54
- [ "$(n "$r")" = "$(n "$2")" ] && exit 0
55
- echo "${r:-none}"
56
- exit 3
57
- POD
58
- }
59
-
60
- # copy-to never overwrites a pod clone of another repository.
61
- copy_guard() {
62
- local folder="$1" mine other code=0
63
- mine="$(git -C "$folder" remote get-url origin 2>/dev/null || true)"
64
- # shellcheck disable=SC2046
65
- other="$(workspace_copy_pod_script | kubectl $(kubectl_flag) exec -i "$POD" \
66
- --namespace "$NAMESPACE" -c workspace -- bash -s -- \
67
- "$PROJECTS_DIR/$(basename "$folder")" "$mine" 2>/dev/null)" || code=$?
68
- if [ "$code" -eq 3 ]; then
69
- echo "✖ $PROJECTS_DIR/$(basename "$folder") in the pod is a git clone with another remote ($other, here: ${mine:-none}); not overwritten" >&2
70
- echo " work in that clone (devzone workspace clone), or remove it first" >&2
71
- return 1
72
- fi
73
- return 0
74
- }
@@ -5,8 +5,12 @@ set -euo pipefail
5
5
 
6
6
  HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7
7
  ROOT="$(cd "$HERE/.." && pwd)"
8
+ # shellcheck disable=SC2034 # read by the argocd scripts and by .devcontainer/argocd/services.sh (shared with the pod)
9
+ RACINE="$ROOT"
8
10
  # Pod, namespace and projects folder inside the container (#399).
11
+ # shellcheck disable=SC2034 # read by the scripts sourced from scripts/workspace/
9
12
  POD="devzone-workspace-0"
13
+ # shellcheck disable=SC2034 # read by the scripts sourced from scripts/workspace/
10
14
  NAMESPACE="devzone-workspace"
11
15
  PROJECTS_DIR="/workspaces/projets"
12
16
  # compatibility alias, removed with lot 4 (#509)
@@ -116,57 +120,6 @@ shell_workspace() {
116
120
  kubectl $(kubectl_flag) exec -it devzone-workspace-0 --namespace devzone-workspace -c workspace -- bash
117
121
  }
118
122
 
119
- # VS Code steps (#399): attach to the pod with Kubernetes and Dev Containers
120
- # extensions, without any command other than devzone.
121
- vscode_workspace() {
122
- cat <<EOF
123
- Attach VS Code to the pod: "Kubernetes" and "Dev Containers" extensions
124
- 1. kubectl context: devzone — namespace $NAMESPACE, pod $POD, container workspace
125
- 2. Kubernetes view: right-click the workspace container,
126
- "Attach to Running Kubernetes Container"
127
- (with Dev Containers extension: "Dev Containers: Attach to Running Container")
128
- 3. Open folder $PROJECTS_DIR in the attached window
129
- Pod not ready: devzone workspace status
130
- EOF
131
- }
132
-
133
- # Copies a workstation folder to $PROJECTS_DIR in the pod (#399, kubectl cp):
134
- # the project keeps its folder name in the pod.
135
- copy_to() {
136
- local folder="${1:-}"
137
- if [ -z "$folder" ]; then
138
- echo "✖ provide a workstation folder: devzone workspace copy-to <folder>" >&2
139
- exit 1
140
- fi
141
- if [ ! -d "$folder" ]; then
142
- echo "✖ folder not found: $folder" >&2
143
- exit 1
144
- fi
145
- folder="$(cd "$folder" && pwd)"
146
- copy_guard "$folder" || exit 1
147
- # shellcheck disable=SC2046
148
- kubectl $(kubectl_flag) cp "$folder" "$POD:$PROJECTS_DIR/$(basename "$folder")" \
149
- --namespace "$NAMESPACE" -c workspace
150
- }
151
-
152
- # Copies a project from $PROJECTS_DIR in the pod to the workstation (#399, kubectl cp):
153
- # the workstation folder gets the project name.
154
- copy_from() {
155
- local folder="${1:-}"
156
- if [ -z "$folder" ]; then
157
- echo "✖ provide a workstation folder: devzone workspace copy-from <folder>" >&2
158
- exit 1
159
- fi
160
- # Absolute path: "copy-from ." gives the current folder name.
161
- folder="$(cd "$folder" 2>/dev/null && pwd || echo "$folder")"
162
- # shellcheck disable=SC2046
163
- kubectl $(kubectl_flag) cp "$POD:$PROJECTS_DIR/$(basename "$folder")" "$folder" \
164
- --namespace "$NAMESPACE" -c workspace
165
- }
166
-
167
- # French names of the command and compatibility aliases (lot 3, #508)
168
- # shellcheck source=manage/scripts/workspace/workspace-aliases.sh
169
- . "$HERE/scripts/workspace/workspace-aliases.sh"
170
123
  # shellcheck source=manage/scripts/kube-ready.sh
171
124
  . "$HERE/scripts/kube-ready.sh"
172
125
  # shellcheck source=manage/scripts/workspace/workspace-wait.sh
@@ -208,19 +161,14 @@ case "${1:-}" in
208
161
  stop) stop_workspace ;;
209
162
  status) status_workspace ;;
210
163
  shell) shell_workspace ;;
211
- vscode) vscode_workspace ;;
212
- copy-to) copy_to "${@:2}" ;;
213
- copy-from) copy_from "${@:2}" ;;
214
- clone) workspace_clone "${@:2}" ;;
215
164
  ports) ports "${@:2}" ;;
216
165
  services) services "${@:2}" ;;
217
166
  argocd) argocd_cmd "${@:2}" ;;
218
167
  egress) egress_workspace "${@:2}" ;;
219
168
  '' | -h | --help | help)
220
- echo "devzone workspace start|stop|status|shell|vscode|copy-to|copy-from|clone|ports|services|argocd|update|egress"
169
+ echo "devzone workspace start|stop|status|shell|ports|services|argocd|update|egress"
221
170
  echo " start [--image repository:tag] install workspace (image for devzone version by default)"
222
171
  echo " update [--version X.Y.Z] [--yes] move to the latest stable release (or X.Y.Z); the pod is recreated"
223
- echo " clone <url> [<name>] git clone into the pod projects folder (gh credentials, identity, repowarden hooks)"
224
172
  echo " ports [start|stop|status] applications and services from pod on workstation localhost"
225
173
  echo " services enable|disable <service> [options] | status"
226
174
  echo " devzone services (gitlab, postgres, argocd) of the cluster, installed from the workstation"
@@ -229,7 +177,7 @@ case "${1:-}" in
229
177
  echo " egress observation|strict|off|status|allow <domain>|deny <domain> egress proxy of the agent sessions (--pod)"
230
178
  ;;
231
179
  *)
232
- echo "✖ unknown subcommand: $1 (devzone workspace start|stop|status|shell|vscode|copy-to|copy-from|clone|ports|services|argocd|update)" >&2
180
+ echo "✖ unknown subcommand: $1 (devzone workspace start|stop|status|shell|ports|services|argocd|update)" >&2
233
181
  exit 1
234
182
  ;;
235
183
  esac
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devzone",
3
- "version": "7.0.1",
3
+ "version": "7.0.2",
4
4
  "description": "Ton poste de développement Linux, prêt en une commande, identique sur Mac, Windows et Linux.",
5
5
  "license": "GPL-3.0-only",
6
6
  "repository": {
@@ -1,101 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Ticket worktrees (#558), in the Kubernetes workspace pod and in the tools
3
- # container:
4
- # devzone ticket <n> [--repo devzone|repowarden]
5
- # devzone ticket done <n> [--repo devzone|repowarden]
6
- # In the pod: clone /workspaces/projets/<repo>, worktree
7
- # /workspaces/projets/<repo>-wt/<dz|rw>-<n>. In the tools container: clone
8
- # /workspaces/devzone, worktree workspace/wt/dz-<n> (devzone only).
9
- # DEVZONE_TICKET_PROJECTS and DEVZONE_TICKET_TOOLS move those roots (tests).
10
- set -euo pipefail
11
-
12
- PROJECTS="${DEVZONE_TICKET_PROJECTS:-/workspaces/projets}"
13
- TOOLS="${DEVZONE_TICKET_TOOLS:-/workspaces/devzone}"
14
-
15
- refuse() { echo "devzone ticket: $*" >&2; exit 2; }
16
-
17
- usage() {
18
- echo "usage: devzone ticket <n> [--repo devzone|repowarden]" >&2
19
- echo " devzone ticket done <n> [--repo devzone|repowarden]" >&2
20
- exit 1
21
- }
22
-
23
- # Sets CLONE, WT and BASE (worktree folder prefix) for the repo.
24
- ticket_paths() {
25
- local repo="$1" n="$2" prefix
26
- case "$repo" in
27
- devzone) prefix=dz ;;
28
- repowarden) prefix=rw ;;
29
- *) refuse "unknown repo: $repo (devzone or repowarden)" ;;
30
- esac
31
- if [ "${DEVZONE_WORKSPACE:-}" = kubernetes ]; then
32
- CLONE="$PROJECTS/$repo"
33
- WT="$PROJECTS/$repo-wt/$prefix-$n"
34
- else
35
- [ "$repo" = devzone ] || refuse "repo $repo only in the Kubernetes workspace pod"
36
- CLONE="$TOOLS"
37
- WT="$TOOLS/workspace/wt/$prefix-$n"
38
- fi
39
- [ -e "$CLONE/.git" ] || refuse "no clone in $CLONE (from the workstation: devzone workspace clone <url>)"
40
- }
41
-
42
- ticket_start() {
43
- local n="$1" repo="$2" branch
44
- ticket_paths "$repo" "$n"
45
- if [ -e "$WT" ]; then
46
- echo "worktree already there: $WT"
47
- echo "$WT"
48
- return 0
49
- fi
50
- git -C "$CLONE" fetch --quiet origin
51
- mkdir -p "$(dirname "$WT")"
52
- git -C "$CLONE" worktree add --quiet --detach "$WT" origin/develop
53
- # repowarden creates the ticket branch from develop and links it
54
- if ! (cd "$WT" && repowarden ticket "$n"); then
55
- git -C "$CLONE" worktree remove --force "$WT" || true
56
- refuse "repowarden ticket $n failed, worktree removed"
57
- fi
58
- branch="$(git -C "$WT" branch --show-current)"
59
- echo "ticket #$n: branch ${branch:-none}"
60
- echo "$WT"
61
- }
62
-
63
- ticket_done() {
64
- local n="$1" repo="$2" branch
65
- ticket_paths "$repo" "$n"
66
- [ -d "$WT" ] || refuse "no worktree for ticket $n: $WT"
67
- if [ -n "$(git -C "$WT" status --porcelain)" ]; then
68
- refuse "worktree $WT is not clean, commit or discard first"
69
- fi
70
- branch="$(git -C "$WT" branch --show-current)"
71
- if [ -n "$branch" ] && git -C "$CLONE" ls-remote --exit-code --heads origin "$branch" >/dev/null 2>&1; then
72
- refuse "branch $branch still exists on origin: merge the pull request first"
73
- fi
74
- git -C "$CLONE" worktree remove "$WT"
75
- if [ -n "$branch" ]; then git -C "$CLONE" branch -D "$branch" >/dev/null; fi
76
- echo "ticket #$n: worktree $WT and local branch ${branch:-none} removed"
77
- }
78
-
79
- main() {
80
- local action=start n="" repo=devzone
81
- [ "${1:-}" != "done" ] || { action="done"; shift; }
82
- while [ $# -gt 0 ]; do
83
- case "$1" in
84
- --repo)
85
- [ $# -ge 2 ] || usage
86
- repo="$2"
87
- shift 2
88
- ;;
89
- -*) usage ;;
90
- *)
91
- [ -z "$n" ] || usage
92
- n="$1"
93
- shift
94
- ;;
95
- esac
96
- done
97
- case "$n" in '' | *[!0-9]*) usage ;; esac
98
- if [ "$action" = "done" ]; then ticket_done "$n" "$repo"; else ticket_start "$n" "$repo"; fi
99
- }
100
-
101
- main "$@"
@@ -1,21 +0,0 @@
1
- #!/usr/bin/env bash
2
- # Compatibility aliases of the workspace functions renamed during the English
3
- # migration (#502, lot 3), sourced by manage/workspace.sh. The old French names
4
- # of the subcommands are refused by reject_renamed (.devcontainer/command-aliases.sh, #695).
5
- # bash 3.2 (macOS).
6
-
7
- # compatibility aliases, removed with lot 4 (#509); RACINE and ICI are still
8
- # read by the scripts of the lot 5 files (argocd-*.sh, services-workspace.sh)
9
- # shellcheck disable=SC2034
10
- RACINE="$ROOT"
11
- # shellcheck disable=SC2034
12
- ICI="$HERE"
13
- drapeau_kubectl() { kubectl_flag "$@"; }
14
- drapeau_helm() { helm_flag "$@"; }
15
- chemin_chart() { chart_path "$@"; }
16
- image_par_defaut() { default_image_tag "$@"; }
17
- demarrer() { start_workspace "$@"; }
18
- arreter() { stop_workspace "$@"; }
19
- etat() { status_workspace "$@"; }
20
- copier_vers() { copy_to "$@"; }
21
- copier_depuis() { copy_from "$@"; }