fix(down): reuse Mode.Valid() instead of re-deriving legal values

ImagesToPrune's own check duplicated the same set of legal
ImagePruneMode values down() already validates upfront, risking silent
drift if a mode is ever added. Reuse Valid() instead.

Suggested-by: glours https://github.com/docker/compose/pull/14149#discussion_r4069721340
Signed-off-by: Nicolas De Loof <[email protected]>
This commit is contained in:
Nicolas De Loof
2026-10-06 11:31:22 +02:00
committed by Guillaume Lours
parent 53198ab17a
commit b134f8af37
+1 -1
View File
@@ -99,7 +99,7 @@ func imageBelongsToKnownService(project *types.Project, removeOrphans bool, img
func (p *ImagePruner) ImagesToPrune(ctx context.Context, opts ImagePruneOptions) ([]string, error) {
if opts.Mode == ImagePruneNone {
return nil, nil
} else if opts.Mode != ImagePruneLocal && opts.Mode != ImagePruneAll {
} else if !opts.Mode.Valid() {
return nil, fmt.Errorf("unsupported image prune mode: %s", opts.Mode)
}
var images []string