compose/internal/e2e/testdata/TestRestartRefusesJob
Nicolas De Loof 65c301a069
Some checks are pending
ci / validate (lint) (push) Waiting to run
ci / validate (relay-lint) (push) Waiting to run
ci / validate (relay-test) (push) Waiting to run
ci / validate (validate-docs) (push) Waiting to run
ci / validate (validate-go-mod) (push) Waiting to run
ci / validate (validate-headers) (push) Waiting to run
ci / validate (validate-mocks) (push) Waiting to run
ci / binary (push) Waiting to run
ci / binary-finalize (push) Blocked by required conditions
ci / bin-image-test (push) Waiting to run
ci / relay-image-test (push) Waiting to run
ci / test (push) Waiting to run
ci / e2e (plugin, oldstable, graphdriver) (push) Waiting to run
ci / e2e (standalone, oldstable, graphdriver) (push) Waiting to run
ci / e2e (plugin, stable, containerd) (push) Waiting to run
ci / e2e (plugin, stable, graphdriver) (push) Waiting to run
ci / e2e (standalone, stable, containerd) (push) Waiting to run
ci / e2e (standalone, stable, graphdriver) (push) Waiting to run
ci / e2e (plugin, test, graphdriver, jobs extension) (push) Waiting to run
ci / coverage (push) Blocked by required conditions
ci / ci-ok (push) Blocked by required conditions
ci / release (push) Blocked by required conditions
merge / bin-image-prepare (push) Waiting to run
merge / bin-image (push) Blocked by required conditions
merge / relay-image (push) Waiting to run
merge / module-image (push) Waiting to run
Scorecards supply-chain security / Scorecards analysis (push) Waiting to run
zizmor / zizmor (push) Waiting to run
cli: one project-resolution story — single name precedence, no swallowed load error, strict service validation
projectOrName and toProjectName resolved the project with opposite
precedences, and projectOrName silently swallowed any load error when
COMPOSE_PROJECT_NAME was set: a broken compose file sent stop, down,
ps... into label-based reconstruction without a word — even when the
file was named explicitly with --file.

One precedence now, documented on both resolvers and applied
identically by compose-go while loading: --project-name, then
COMPOSE_PROJECT_NAME, then the model's name. The failure policy
becomes explicit: an unreadable explicit --file is a hard error; no
file around with COMPOSE_PROJECT_NAME set stays the silent file-less
workflow; a present-but-broken implicit file falls back to label-based
mode with a warning.

Service-name validation follows one rule — strict whenever a model is
available: restart and wait no longer silently no-op on a typo
(validateServiceNames, profile-disabled services remain legitimate
targets), and the hand-rolled checks in ps and volumes are removed as
dead code, the load-time selection already rejecting unknown names
(pinned by test).

Epic #14074, F.4.

Rebased onto main, which since merged the jobs work (#14093, #14234):
projectOrName's job-target detection (jobTargetErr) is restored ahead
of the new explicit-file hard-error branch -- the file loaded fine
here, only the target's selection failed -- and validateServiceNames
now checks project.AllJobs() too, since restart/wait route their
service arguments through it instead of projectOrName's own selection.

docker-agent review: the "compose file found but could not be loaded"
warning's suppression guard only matched errdefs.IsNotFoundError
(compose-go's own ErrNotFound sentinel) -- a raw os.ErrNotExist (e.g. a
nonexistent --project-directory) wasn't recognized and would have
printed a misleading warning. Added errors.Is(err, os.ErrNotExist) as
a fallback, and TestProjectOrNameResolution now asserts the warning's
presence/absence in both directions instead of just the fallback name.

COMPOSE_FILE counts as an explicit file, like --file (explicitFile():
process environment or .env, as compose-go reads it): it is loaded even
with --project-name (docker/compose#14535, also addressed by #14540), and
failing to load it is a hard error rather than a label-based fallback.
Consistent with #14540's reading of COMPOSE_FILE as the environment
equivalent of -f.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2026-11-25 16:27:43 +01:00
..
compose.yaml cli: one project-resolution story — single name precedence, no swallowed load error, strict service validation 2026-11-25 16:27:43 +01:00