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>
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>