container_list: guard against list filter being nil
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
e99a78edff
commit
99e8676967
1 changed files with 31 additions and 28 deletions
|
@ -38,12 +38,14 @@ func (s *Server) ListContainers(ctx context.Context, req *pb.ListContainersReque
|
||||||
logrus.Debugf("ListContainersRequest %+v", req)
|
logrus.Debugf("ListContainersRequest %+v", req)
|
||||||
|
|
||||||
var ctrs []*pb.Container
|
var ctrs []*pb.Container
|
||||||
filter := req.Filter
|
filter := req.GetFilter()
|
||||||
ctrList, err := s.ContainerServer.ListContainers()
|
ctrList, err := s.ContainerServer.ListContainers()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if filter != nil {
|
||||||
|
|
||||||
// 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)
|
||||||
|
@ -76,6 +78,7 @@ func (s *Server) ListContainers(ctx context.Context, req *pb.ListContainersReque
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for _, ctr := range ctrList {
|
for _, ctr := range ctrList {
|
||||||
podSandboxID := ctr.Sandbox()
|
podSandboxID := ctr.Sandbox()
|
||||||
|
|
Loading…
Reference in a new issue