Repository navigation
Conversation
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟢 APPROVE
docker-agent
left a comment
There was a problem hiding this comment.
This review covers only the commits pushed since a7cd4a2.
Assessment: 🟢 APPROVE
The incremental diff fixes TestResolveMaxConcurrency exactly as the prior resolved review thread requested: the test now reads the cobra-bound --parallel value via root.Flags().GetInt("parallel") and passes it to resolveMaxConcurrency, rather than the hardcoded 4. The three test-case changes follow directly from that fix:
- "default without environment" (new case): no args, no env →
parallelis-1(the flag default),want: -1. Correct. - "flag value without environment":
--parallel 2→parallel = 2,want: 2. Correct. - "flag wins over environment":
--parallel 2+ env8→ flag wins,parallel = 2,want: 2. Correct (was previouslywant: 4, a hardcoded value that gave false confidence).
No production code is changed. No bugs introduced.
46d350b to
6d3ca02
Compare
glours
left a comment
There was a problem hiding this comment.
Changes requested on the ansi row (see inline, cli_helpers_test.go:346); the rest is small.
The description says "the incompatible-flag matrix of up and create" is asserted, but only validateFlags is exercised. The inline checks in create.go:67-72 (--build/--no-build, --force-recreate/--no-recreate), run.go:175 (--service-ports/--publish) and the flag→field bindings (e.g. create.pullChanged = …Changed("pull"), up.go:123) aren't pinned: removing any of them keeps the suite green. Narrow the description to validateFlags, or add a daemon-free test on the real commands (upCommand(...), ParseFlags, PreRunE).
Nits:
- cli_helpers_test.go:198-204 "publish is ignored with service-ports": run's PreRunE (run.go:175) rejects that combination before
apply. The row only pins theapplyguard (run.go:96), name it that way. - cli_helpers_test.go:111
filterByStatus(nil): unreachable,runPsguards onlen(opts.Status) != 0. Pins incidental behaviour. - cli_helpers_test.go:220-222, up_flags_test.go:185, :308-309: assertions on compose-go /
strconvwording break on a dependency bump.ErrorContainson the offending input is enough. - cli_helpers_test.go:158 "by default" uses
interactive=false, the flag default istrue(run.go:252). :435 "unset" sets the var to empty. up_flags_test.go:83 should name--renew-anon-volumes, notno-inherit. - build/run/ps/scale tests belong in
build_test.go/run_test.go(one test file per production file).
81732f1 to
0c10160
Compare
docker-agent
left a comment
There was a problem hiding this comment.
Assessment: 🟡 NEEDS ATTENTION
0c10160 to
0787f8b
Compare
validateFlags, the recreate strategies, createOptions.Apply and upOptions.apply encode the incompatible flag combinations of up/create and had no tests. Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
…mands
The --ansi flag is registered on the compose command only, but the
pre-run hook checks whether it was set on the command being executed,
which is the sub-command (`ps`, `up`...). `Changed("ansi")` was therefore
always false there, and COMPOSE_ANSI overrode the flag:
COMPOSE_ANSI=always docker compose --ansi never ps
resolved to "always" instead of "never".
Look the flag up on the compose command, as resolveMaxConcurrency already
does for --parallel, through a helper both now share.
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Pin the mapping from flags to project/build options and the env/flag precedence rules (COMPOSE_ANSI, COMPOSE_PARALLEL_LIMIT, --workdir). Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
0787f8b to
d02004b
Compare
This PR adds table-driven unit tests that pin the flag validation and flag-to-option mapping of the
composeCLI, without needing a Docker daemon, and fixes one bug those tests uncovered: an explicit--ansidid not win overCOMPOSE_ANSI.Context
cmd/composesits at roughly a quarter of statement coverage, yet it holds the user-facing flag logic: which combinations are rejected, how flags and environment variables take precedence, and how flags end up in project and build options. That logic is easy to break by accident during refactors and cheap to test, since it is pure and never touches the engine.What the PR brings
The incompatible-flag matrix of
upandcreate(--wait,--detach,--abort-on-container-*,--build/--no-build, the--no-recreatefamily,--watch) is now asserted case by case with its exact error message, along with the implications between flags (--exit-code-fromimplies abort-on-exit,--waitimplies detach). The recreate strategies,--pullpolicy handling,--scaleparsing,up --no-deps/--exit-code-fromand therunoption mapping (tty/stdin,--service-portsversus--publish, volumes,--no-deps) are covered too.Around them, the PR pins the
scaleargument parser,ps --filterparsing and status filtering, the legacy flag-name normalization ofrun, the--ssh/BUILDX_BUILDERhandling ofbuild, and the root-level precedence rules (--ansivs--no-ansivsCOMPOSE_ANSI,--parallelvsCOMPOSE_PARALLEL_LIMIT, deprecated--workdir, env-file path normalization).While pinning the root-level precedence rules, the tests showed that
COMPOSE_ANSI=always docker compose --ansi never psresolved toalways:--ansiis registered on the compose command only, but the pre-run hook checked whether it had been set on the executed sub-command, so the check was always false and the environment variable always won. The fix, in its own commit ahead of the tests that rely on it, looks the flag up on the compose command, the way--parallelversusCOMPOSE_PARALLEL_LIMITalready did. It is covered by a unit test on a root plus sub-command, and by a run of the real command tree.Guardrails: the only production change is that one-commit
--ansifix; everything else is tests, with no Docker daemon and no mocks of the API.cmd/compatibilitywas already at 100% and is untouched.AI disclosure: prepared with GitHub Copilot CLI, orchestrated by Claude Code, on behalf of and under the direction of the submitter.