mirror of
https://github.com/containers/podman.git
synced 2025-11-01 19:21:04 +08:00
Vendor common
Added patch provided by rhatdan to add support for shareable [NO NEW TESTS NEEDED] Signed-off-by: rvandernoort <s.r.vandernoort@student.tudelft.nl>
This commit is contained in:
22
vendor/github.com/containers/common/libimage/filters.go
generated
vendored
22
vendor/github.com/containers/common/libimage/filters.go
generated
vendored
@ -95,9 +95,15 @@ func (r *Runtime) compileImageFilters(ctx context.Context, options *ListImagesOp
|
||||
for _, f := range options.Filters {
|
||||
var key, value string
|
||||
var filter filterFunc
|
||||
split := strings.SplitN(f, "=", 2)
|
||||
if len(split) != 2 {
|
||||
return nil, errors.Errorf("invalid image filter %q: must be in the format %q", f, "filter=value")
|
||||
negate := false
|
||||
split := strings.SplitN(f, "!=", 2)
|
||||
if len(split) == 2 {
|
||||
negate = true
|
||||
} else {
|
||||
split = strings.SplitN(f, "=", 2)
|
||||
if len(split) != 2 {
|
||||
return nil, errors.Errorf("invalid image filter %q: must be in the format %q", f, "filter=value or filter!=value")
|
||||
}
|
||||
}
|
||||
|
||||
key = split[0]
|
||||
@ -182,12 +188,22 @@ func (r *Runtime) compileImageFilters(ctx context.Context, options *ListImagesOp
|
||||
default:
|
||||
return nil, errors.Errorf("unsupported image filter %q", key)
|
||||
}
|
||||
if negate {
|
||||
filter = negateFilter(filter)
|
||||
}
|
||||
filters[key] = append(filters[key], filter)
|
||||
}
|
||||
|
||||
return filters, nil
|
||||
}
|
||||
|
||||
func negateFilter(f filterFunc) filterFunc {
|
||||
return func(img *Image) (bool, error) {
|
||||
b, err := f(img)
|
||||
return !b, err
|
||||
}
|
||||
}
|
||||
|
||||
func (r *Runtime) containers(duplicate map[string]string, key, value string, externalFunc IsExternalContainerFunc) error {
|
||||
if exists, ok := duplicate[key]; ok && exists != value {
|
||||
return errors.Errorf("specifying %q filter more than once with different values is not supported", key)
|
||||
|
||||
Reference in New Issue
Block a user