mirror of
https://github.com/containers/podman.git
synced 2025-06-24 19:42:56 +08:00
Merge pull request #5236 from marusak/filter_by_id
apiv2: Image filtering and fixup docs
This commit is contained in:
@ -102,6 +102,13 @@ func ReferenceFilter(ctx context.Context, referenceFilter string) ResultFilter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// IdFilter allows you to filter by image Id
|
||||||
|
func IdFilter(idFilter string) ResultFilter {
|
||||||
|
return func(i *Image) bool {
|
||||||
|
return i.ID() == idFilter
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// OutputImageFilter allows you to filter by an a specific image name
|
// OutputImageFilter allows you to filter by an a specific image name
|
||||||
func OutputImageFilter(userImage *Image) ResultFilter {
|
func OutputImageFilter(userImage *Image) ResultFilter {
|
||||||
return func(i *Image) bool {
|
return func(i *Image) bool {
|
||||||
@ -165,6 +172,8 @@ func (ir *Runtime) createFilterFuncs(filters []string, img *Image) ([]ResultFilt
|
|||||||
case "reference":
|
case "reference":
|
||||||
referenceFilter := strings.Join(splitFilter[1:], "=")
|
referenceFilter := strings.Join(splitFilter[1:], "=")
|
||||||
filterFuncs = append(filterFuncs, ReferenceFilter(ctx, referenceFilter))
|
filterFuncs = append(filterFuncs, ReferenceFilter(ctx, referenceFilter))
|
||||||
|
case "id":
|
||||||
|
filterFuncs = append(filterFuncs, IdFilter(splitFilter[1]))
|
||||||
default:
|
default:
|
||||||
return nil, errors.Errorf("invalid filter %s ", splitFilter[0])
|
return nil, errors.Errorf("invalid filter %s ", splitFilter[0])
|
||||||
}
|
}
|
||||||
|
@ -615,21 +615,21 @@ func (s *APIServer) registerContainersHandlers(r *mux.Router) error {
|
|||||||
// name: filters
|
// name: filters
|
||||||
// type: string
|
// type: string
|
||||||
// description: |
|
// description: |
|
||||||
// Returns a list of containers.
|
// A JSON encoded value of the filters (a `map[string][]string`) to process on the containers list. Available filters:
|
||||||
// - ancestor=(<image-name>[:<tag>], <image id>, or <image@digest>)
|
// - `ancestor`=(`<image-name>[:<tag>]`, `<image id>`, or `<image@digest>`)
|
||||||
// - before=(<container id> or <container name>)
|
// - `before`=(`<container id>` or `<container name>`)
|
||||||
// - expose=(<port>[/<proto>]|<startport-endport>/[<proto>])
|
// - `expose`=(`<port>[/<proto>]` or `<startport-endport>/[<proto>]`)
|
||||||
// - exited=<int> containers with exit code of <int>
|
// - `exited=<int>` containers with exit code of `<int>`
|
||||||
// - health=(starting|healthy|unhealthy|none)
|
// - `health`=(`starting`, `healthy`, `unhealthy` or `none`)
|
||||||
// - id=<ID> a container's ID
|
// - `id=<ID>` a container's ID
|
||||||
// - is-task=(true|false)
|
// - `is-task`=(`true` or `false`)
|
||||||
// - label=key or label="key=value" of a container label
|
// - `label`=(`key` or `"key=value"`) of an container label
|
||||||
// - name=<name> a container's name
|
// - `name=<name>` a container's name
|
||||||
// - network=(<network id> or <network name>)
|
// - `network`=(`<network id>` or `<network name>`)
|
||||||
// - publish=(<port>[/<proto>]|<startport-endport>/[<proto>])
|
// - `publish`=(`<port>[/<proto>]` or `<startport-endport>/[<proto>]`)
|
||||||
// - since=(<container id> or <container name>)
|
// - `since`=(`<container id>` or `<container name>`)
|
||||||
// - status=(created|restarting|running|removing|paused|exited|dead)
|
// - `status`=(`created`, `restarting`, `running`, `removing`, `paused`, `exited` or `dead`)
|
||||||
// - volume=(<volume name> or <mount point destination>)
|
// - `volume`=(`<volume name>` or `<mount point destination>`)
|
||||||
// produces:
|
// produces:
|
||||||
// - application/json
|
// - application/json
|
||||||
// responses:
|
// responses:
|
||||||
|
@ -648,6 +648,7 @@ func (s *APIServer) registerImagesHandlers(r *mux.Router) error {
|
|||||||
// - `dangling=true`
|
// - `dangling=true`
|
||||||
// - `label=key` or `label="key=value"` of an image label
|
// - `label=key` or `label="key=value"` of an image label
|
||||||
// - `reference`=(`<image-name>[:<tag>]`)
|
// - `reference`=(`<image-name>[:<tag>]`)
|
||||||
|
// - `id`=(`<image-id>`)
|
||||||
// - `since`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`)
|
// - `since`=(`<image-name>[:<tag>]`, `<image id>` or `<image@digest>`)
|
||||||
// type: string
|
// type: string
|
||||||
// produces:
|
// produces:
|
||||||
|
Reference in New Issue
Block a user