fix: [nomad-step-0] S0.1-fix — bin/disinto swallows --backend=nomad as repo_url positional (#835)
All checks were successful
All checks were successful
Why: disinto_init() consumed $1 as repo_url before the argparse loop ran,
so `disinto init --backend=nomad --empty` had --backend=nomad swallowed
into repo_url, backend stayed at its "docker" default, and the --empty
validation then produced the nonsense "--empty is only valid with
--backend=nomad" error — flagged during S0.1 end-to-end verification on
a fresh LXC. nomad backend takes no positional anyway; the LXC already
has the repo cloned by the operator.
Change: only consume $1 as repo_url if it doesn't start with "--", then
defer the "repo URL required" check to after argparse (so the docker
path still errors with a helpful message on a missing positional, not
"Unknown option: --backend=docker").
Verified acceptance criteria:
1. init --backend=nomad --empty → dispatches to nomad
2. init --backend=nomad --empty --dry-run → 9-step plan, exit 0
3. init <repo-url> → docker path unchanged
4. init → "repo URL required"
5. init --backend=docker → "repo URL required"
(not "Unknown option")
6. shellcheck clean
Tests: 4 new regression cases in tests/disinto-init-nomad.bats covering
flag-first nomad invocation (both --flag=value and --flag value forms),
no-args docker default, and --backend=docker missing-positional error
path. Full suite: 10/10 pass.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
0850e83ec6
commit
72ed1f112d
2 changed files with 60 additions and 6 deletions
27
bin/disinto
27
bin/disinto
|
|
@ -707,13 +707,18 @@ _disinto_init_nomad() {
|
|||
}
|
||||
|
||||
disinto_init() {
|
||||
local repo_url="${1:-}"
|
||||
if [ -z "$repo_url" ]; then
|
||||
echo "Error: repo URL required" >&2
|
||||
echo "Usage: disinto init <repo-url>" >&2
|
||||
exit 1
|
||||
# Only consume $1 as repo_url if it looks like a positional arg (not a
|
||||
# flag). The nomad backend (#835) takes no positional — the LXC already
|
||||
# has the repo cloned by the operator, and repo_url is a docker-backend
|
||||
# concept. Eagerly consuming `--backend=nomad` as repo_url produced the
|
||||
# nonsense "--empty is only valid with --backend=nomad" error seen in
|
||||
# S0.1 end-to-end testing on a fresh LXC. Defer the "repo URL required"
|
||||
# check to after argparse, where we know the backend.
|
||||
local repo_url=""
|
||||
if [ $# -gt 0 ] && [[ "$1" != --* ]]; then
|
||||
repo_url="$1"
|
||||
shift
|
||||
fi
|
||||
shift
|
||||
|
||||
# Parse flags
|
||||
local branch="" repo_root="" ci_id="0" auto_yes=false forge_url_flag="" bare=false rotate_tokens=false use_build=false dry_run=false backend="docker" empty=false
|
||||
|
|
@ -741,6 +746,16 @@ disinto_init() {
|
|||
*) echo "Error: invalid --backend value '${backend}' (expected: docker|nomad)" >&2; exit 1 ;;
|
||||
esac
|
||||
|
||||
# Docker backend requires a repo_url positional; nomad doesn't use one.
|
||||
# This check must run *after* argparse so `--backend=docker` (with no
|
||||
# positional) errors with a helpful message instead of the misleading
|
||||
# "Unknown option: --backend=docker".
|
||||
if [ "$backend" = "docker" ] && [ -z "$repo_url" ]; then
|
||||
echo "Error: repo URL required" >&2
|
||||
echo "Usage: disinto init <repo-url> [options]" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# --empty is nomad-only today (the docker path has no concept of an
|
||||
# "empty cluster"). Reject explicitly rather than letting it silently
|
||||
# do nothing on --backend=docker.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue