mirror of
https://github.com/docker/compose.git
synced 2026-10-12 02:13:08 +00:00
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:
committed by
Guillaume Lours
parent
53198ab17a
commit
b134f8af37
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user