From cc398cfc1bcc5160863dbd9f408edfdd2ff1a0d9 Mon Sep 17 00:00:00 2001 From: Daniel J Walsh Date: Thu, 27 Jun 2024 14:27:36 -0400 Subject: [PATCH] Display same error as split Partial fix for https://github.com/containers/podman/issues/23120 Working on a fix for this crash, but want same error to come back as non-remote case. Signed-off-by: Daniel J Walsh --- libimage/filters.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libimage/filters.go b/libimage/filters.go index f0cf2e5b3..2465d370d 100644 --- a/libimage/filters.go +++ b/libimage/filters.go @@ -88,6 +88,8 @@ func (r *Runtime) compileImageFilters(ctx context.Context, options *ListImagesOp return tree, nil } + filterInvalidValue := `invalid image filter %q: must be in the format "filter=value or filter!=value"` + var wantedReferenceMatches, unwantedReferenceMatches []string filters := map[string][]filterFunc{} duplicate := map[string]string{} @@ -101,7 +103,7 @@ func (r *Runtime) compileImageFilters(ctx context.Context, options *ListImagesOp } else { split = strings.SplitN(f, "=", 2) if len(split) != 2 { - return nil, fmt.Errorf("invalid image filter %q: must be in the format %q", f, "filter=value or filter!=value") + return nil, fmt.Errorf(filterInvalidValue, f) } } @@ -195,7 +197,7 @@ func (r *Runtime) compileImageFilters(ctx context.Context, options *ListImagesOp filter = filterBefore(until) default: - return nil, fmt.Errorf("unsupported image filter %q", key) + return nil, fmt.Errorf(filterInvalidValue, key) } if negate { filter = negateFilter(filter)