Commit graph

2 commits

Author SHA1 Message Date
Nicolas De Loof
b3c39f17a6 fix(api): list every accepted value in InvalidOptionError
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
DownOptions.Validate omitted the empty ImagePruneNone value from the
allowed list, so the error did not tell callers that "" is accepted.
Quote the allowed values so an empty one stays readable, fall back to a
generic message when no closed set is given, and word the Logs Index
error properly when no service is selected.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2026-11-27 10:12:06 +01:00
Nicolas De Loof
75f0c3417d feat(api): Validate for the options that have invalid values or combinations
Logs, Events, Publish and Down each accept options that cannot work, and
fail late or not at all:

- LogOptions.Index selects a replica of one service. With no service the
  lookup indexes an empty slice and panics, with several the others are
  silently ignored. The CLI refuses it, the library did not.
- EventsOptions.Consumer is called for every event, and a nil one panics when
  the first arrives.
- PublishOptions.OCIVersion is only checked once the layers are pushed.
- DownOptions.Images was validated inline in down(), with a message nothing
  could match.

Give each a Validate, and call it first from the operation. Invalid values
match the new ErrInvalidOption (InvalidOptionError, which also covers a
required option left unset through its Reason), and the Logs combination
matches the existing ErrIncompatibleOptions. The message for an unknown image
prune mode changes accordingly; nothing else that worked is rejected.

Signed-off-by: Nicolas De Loof <nicolas.deloof@gmail.com>
2026-11-27 10:12:06 +01:00