mirror of
https://github.com/moby/moby.git
synced 2022-11-09 12:21:53 -05:00
daemon/containerd: validate image filters
Not all filters are implemented yet, so make sure an error is returned if a not-yet implemented filter is used. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
4d3b32bf3d
commit
669fbed1ac
1 changed files with 12 additions and 0 deletions
|
@ -11,10 +11,22 @@ import (
|
||||||
"github.com/opencontainers/image-spec/identity"
|
"github.com/opencontainers/image-spec/identity"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var acceptedImageFilterTags = map[string]bool{
|
||||||
|
"dangling": false, // TODO(thaJeztah): implement "dangling" filter: see https://github.com/moby/moby/issues/43846
|
||||||
|
"label": true,
|
||||||
|
"before": true,
|
||||||
|
"since": true,
|
||||||
|
"reference": false, // TODO(thaJeztah): implement "reference" filter: see https://github.com/moby/moby/issues/43847
|
||||||
|
}
|
||||||
|
|
||||||
// Images returns a filtered list of images.
|
// Images returns a filtered list of images.
|
||||||
//
|
//
|
||||||
// TODO(thaJeztah): sort the results by created (descending); see https://github.com/moby/moby/issues/43848
|
// TODO(thaJeztah): sort the results by created (descending); see https://github.com/moby/moby/issues/43848
|
||||||
func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions) ([]*types.ImageSummary, error) {
|
func (i *ImageService) Images(ctx context.Context, opts types.ImageListOptions) ([]*types.ImageSummary, error) {
|
||||||
|
if err := opts.Filters.Validate(acceptedImageFilterTags); err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
filter, err := i.setupFilters(ctx, opts.Filters)
|
filter, err := i.setupFilters(ctx, opts.Filters)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue