|
@@ -36,6 +36,7 @@ var acceptedPsFilterTags = map[string]bool{
|
|
"since": true,
|
|
"since": true,
|
|
"volume": true,
|
|
"volume": true,
|
|
"network": true,
|
|
"network": true,
|
|
|
|
+ "is-task": true,
|
|
}
|
|
}
|
|
|
|
|
|
// iterationAction represents possible outcomes happening during the container iteration.
|
|
// iterationAction represents possible outcomes happening during the container iteration.
|
|
@@ -79,11 +80,14 @@ type listContext struct {
|
|
exitAllowed []int
|
|
exitAllowed []int
|
|
|
|
|
|
// beforeFilter is a filter to ignore containers that appear before the one given
|
|
// beforeFilter is a filter to ignore containers that appear before the one given
|
|
- // this is used for --filter=before= and --before=, the latter is deprecated.
|
|
|
|
beforeFilter *container.Container
|
|
beforeFilter *container.Container
|
|
// sinceFilter is a filter to stop the filtering when the iterator arrive to the given container
|
|
// sinceFilter is a filter to stop the filtering when the iterator arrive to the given container
|
|
- // this is used for --filter=since= and --since=, the latter is deprecated.
|
|
|
|
sinceFilter *container.Container
|
|
sinceFilter *container.Container
|
|
|
|
+
|
|
|
|
+ // taskFilter tells if we should filter based on wether a container is part of a task
|
|
|
|
+ taskFilter bool
|
|
|
|
+ // isTask tells us if the we should filter container that are a task (true) or not (false)
|
|
|
|
+ isTask bool
|
|
// ContainerListOptions is the filters set by the user
|
|
// ContainerListOptions is the filters set by the user
|
|
*types.ContainerListOptions
|
|
*types.ContainerListOptions
|
|
}
|
|
}
|
|
@@ -241,6 +245,19 @@ func (daemon *Daemon) foldFilter(config *types.ContainerListOptions) (*listConte
|
|
return nil, err
|
|
return nil, err
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ var taskFilter, isTask bool
|
|
|
|
+ if psFilters.Include("is-task") {
|
|
|
|
+ if psFilters.ExactMatch("is-task", "true") {
|
|
|
|
+ taskFilter = true
|
|
|
|
+ isTask = true
|
|
|
|
+ } else if psFilters.ExactMatch("is-task", "false") {
|
|
|
|
+ taskFilter = true
|
|
|
|
+ isTask = false
|
|
|
|
+ } else {
|
|
|
|
+ return nil, fmt.Errorf("Invalid filter 'is-task=%s'", psFilters.Get("is-task"))
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
var beforeContFilter, sinceContFilter *container.Container
|
|
var beforeContFilter, sinceContFilter *container.Container
|
|
|
|
|
|
err = psFilters.WalkValues("before", func(value string) error {
|
|
err = psFilters.WalkValues("before", func(value string) error {
|
|
@@ -286,6 +303,8 @@ func (daemon *Daemon) foldFilter(config *types.ContainerListOptions) (*listConte
|
|
exitAllowed: filtExited,
|
|
exitAllowed: filtExited,
|
|
beforeFilter: beforeContFilter,
|
|
beforeFilter: beforeContFilter,
|
|
sinceFilter: sinceContFilter,
|
|
sinceFilter: sinceContFilter,
|
|
|
|
+ taskFilter: taskFilter,
|
|
|
|
+ isTask: isTask,
|
|
ContainerListOptions: config,
|
|
ContainerListOptions: config,
|
|
names: daemon.nameIndex.GetAll(),
|
|
names: daemon.nameIndex.GetAll(),
|
|
}, nil
|
|
}, nil
|
|
@@ -325,6 +344,12 @@ func includeContainerInList(container *container.Container, ctx *listContext) it
|
|
return excludeContainer
|
|
return excludeContainer
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if ctx.taskFilter {
|
|
|
|
+ if ctx.isTask != container.Managed {
|
|
|
|
+ return excludeContainer
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
// Do not include container if any of the labels don't match
|
|
// Do not include container if any of the labels don't match
|
|
if !ctx.filters.MatchKVList("label", container.Config.Labels) {
|
|
if !ctx.filters.MatchKVList("label", container.Config.Labels) {
|
|
return excludeContainer
|
|
return excludeContainer
|