diff --git a/CHANGELOG.md b/CHANGELOG.md index 31292a1..6c9654c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,13 @@ workflow refuses a tag whose version has no entry here. ## [Unreleased] +### Changed + +- **`urbex-op`'s default workspace is `~/urbex-work`**, as in the docs + and the Claude Code plugin (it was `~/urbex-workspace`). A workspace + in `~/urbex-workspace` is still found when `~/urbex-work` doesn't + exist; `-w` and `URBEX_WORKSPACE` choose any other. + ## [0.1.0] - 2026-11-17 The first preview release: urbex as binaries for Linux and macOS (amd64, diff --git a/tools/operator/README.md b/tools/operator/README.md index 9762731..91dea84 100644 --- a/tools/operator/README.md +++ b/tools/operator/README.md @@ -129,7 +129,7 @@ See *Find every endpoint* in the cookbook | Variable | Default | Meaning | |---|---|---| -| `URBEX_WORKSPACE` | `~/urbex-workspace` | The workspace, if `-w` isn't given. | +| `URBEX_WORKSPACE` | `~/urbex-work` (`~/urbex-workspace`, urbex 0.1's default, if only that exists) | The workspace, if `-w` isn't given. | | `URBEX_OPERATOR_IMAGE` | a release's `urbex-op`: `ghcr.io/urbforge/urbex-op:`; from a checkout: `urbex-operator` | The image runs use (and `build` creates). | | `URBEX_PROXMOX_TOKEN`, `URBEX_CLOUDFLARE_TOKEN`, `URBEX_AGE_KEY` | - | Passed to the container when set; otherwise the credentials file is used. | diff --git a/tools/operator/test-urbex-op.sh b/tools/operator/test-urbex-op.sh index bc244c7..dda7772 100755 --- a/tools/operator/test-urbex-op.sh +++ b/tools/operator/test-urbex-op.sh @@ -67,4 +67,25 @@ check "docker: a bare name, missing, is never pulled" docker urbex-operator none check "docker: a bare name, present, is run" docker urbex-operator urbex-operator local check "docker: a published image, missing, is pulled" docker $published none pull +# The default workspace: ~/urbex-work, or ~/urbex-workspace (urbex 0.1's +# default) when only that one exists (urbforge/urbex#57). +default_ws() { # default_ws NAME WANT [DIR...]: the workspace urbex-op picks with these dirs in HOME + local name=$1 want=$2 home=$tmp/home-$RANDOM bin + shift 2 + mkdir -p "$home" + for d in "$@"; do mkdir -p "$home/$d/home"; done + bin=$(fake podman localhost/urbex-operator) + : >"$tmp/calls" + PATH=$bin:$tools HOME=$home URBEX_OPERATOR_IMAGE=localhost/urbex-operator "$here/urbex-op" true >"$tmp/out" 2>&1 + if grep -q -- "-v $home/$want:/work" "$tmp/calls" || grep -q "no workspace at $home/$want" "$tmp/out"; then + echo "ok $name" + else + echo "FAIL $name: want ~/$want"; sed 's/^/ /' "$tmp/out" "$tmp/calls"; fails=$((fails + 1)) + fi +} +default_ws "default workspace: ~/urbex-work" urbex-work urbex-work +default_ws "default workspace: ~/urbex-workspace when only it exists" urbex-workspace urbex-workspace +default_ws "default workspace: ~/urbex-work when both exist" urbex-work urbex-work urbex-workspace +default_ws "default workspace: ~/urbex-work when none exists" urbex-work + [ $fails -eq 0 ] || { echo "$fails failed"; exit 1; } diff --git a/tools/operator/urbex-op b/tools/operator/urbex-op index 69a6a30..ebf98c8 100755 --- a/tools/operator/urbex-op +++ b/tools/operator/urbex-op @@ -9,7 +9,8 @@ # urbex-op [-w DIR] shell a shell in the container, ready to run urbex # urbex-op [-w DIR] 'COMMANDS' run COMMANDS (bash) in the container # -# DIR defaults to $URBEX_WORKSPACE, then ~/urbex-workspace. Tokens come from +# DIR defaults to $URBEX_WORKSPACE, then ~/urbex-work (~/urbex-workspace, +# urbex 0.1's default, if only that one exists). Tokens come from # the environment if set (URBEX_PROXMOX_TOKEN, URBEX_CLOUDFLARE_TOKEN), else # from the workspace's credentials file - 'set proxmoxToken' puts them there. # @@ -21,7 +22,13 @@ set -euo pipefail # The release workflow sets this in the copy attached to a release. URBEX_OP_VERSION=dev -WS=${URBEX_WORKSPACE:-$HOME/urbex-workspace} +if [ -n "${URBEX_WORKSPACE:-}" ]; then + WS=$URBEX_WORKSPACE +elif [ ! -d "$HOME/urbex-work" ] && [ -d "$HOME/urbex-workspace/home" ]; then + WS=$HOME/urbex-workspace +else + WS=$HOME/urbex-work +fi if [ "${1:-}" = "-w" ]; then WS=$2; shift 2; fi if [ "$URBEX_OP_VERSION" = dev ]; then IMAGE=${URBEX_OPERATOR_IMAGE:-urbex-operator}