Rework function getContainers

- Use canonical way to check if a map contains a key.
- Use "ci" to keep consistence since it is for "containerInfo".

Signed-off-by: Hu Keping <hukeping@huawei.com>
This commit is contained in:
HuKeping 2016-04-22 17:29:30 -04:00
parent 9d30093505
commit 40d42a1aac

View file

@ -9,16 +9,20 @@ type GetContainersTask struct {
}
func (s *Supervisor) getContainers(t *GetContainersTask) error {
if t.ID != "" {
ci := s.containers[t.ID]
if ci == nil {
ci, ok := s.containers[t.ID]
if !ok {
return ErrContainerNotFound
}
t.Containers = append(t.Containers, ci.container)
return nil
}
for _, i := range s.containers {
t.Containers = append(t.Containers, i.container)
for _, ci := range s.containers {
t.Containers = append(t.Containers, ci.container)
}
return nil
}