Specifying a filter with no filtering expressions is now idempotent
Signed-off-by: Yann Ramin <atrus@stackworks.net>
This commit is contained in:
parent
14c1c70407
commit
50c94a9335
2 changed files with 5 additions and 3 deletions
|
@ -30,7 +30,9 @@ func filterContainer(c *pb.Container, filter *pb.ContainerFilter) bool {
|
||||||
|
|
||||||
// filterContainerList applies a protobuf-defined filter to retrieve only intended containers. Not matching
|
// filterContainerList applies a protobuf-defined filter to retrieve only intended containers. Not matching
|
||||||
// the filter is not considered an error but will return an empty response.
|
// the filter is not considered an error but will return an empty response.
|
||||||
func (s *Server) filterContainerList(filter *pb.ContainerFilter) (ctrList []*oci.Container, err error) {
|
func (s *Server) filterContainerList(filter *pb.ContainerFilter, origCtrList []*oci.Container) (ctrList []*oci.Container, err error) {
|
||||||
|
ctrList = origCtrList
|
||||||
|
|
||||||
// Filter using container id and pod id first.
|
// Filter using container id and pod id first.
|
||||||
if filter.Id != "" {
|
if filter.Id != "" {
|
||||||
id, err := s.CtrIDIndex().Get(filter.Id)
|
id, err := s.CtrIDIndex().Get(filter.Id)
|
||||||
|
@ -83,7 +85,7 @@ func (s *Server) ListContainers(ctx context.Context, req *pb.ListContainersReque
|
||||||
}
|
}
|
||||||
|
|
||||||
if filter != nil {
|
if filter != nil {
|
||||||
ctrList, err = s.filterContainerList(filter)
|
ctrList, err = s.filterContainerList(filter, ctrList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ func (s *Server) ListContainerStats(ctx context.Context, req *pb.ListContainerSt
|
||||||
PodSandboxId: req.Filter.PodSandboxId,
|
PodSandboxId: req.Filter.PodSandboxId,
|
||||||
LabelSelector: req.Filter.LabelSelector,
|
LabelSelector: req.Filter.LabelSelector,
|
||||||
}
|
}
|
||||||
ctrList, err = s.filterContainerList(cFilter)
|
ctrList, err = s.filterContainerList(cFilter, ctrList)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue