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:
parent
9d30093505
commit
40d42a1aac
1 changed files with 8 additions and 4 deletions
|
@ -9,16 +9,20 @@ type GetContainersTask struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Supervisor) getContainers(t *GetContainersTask) error {
|
func (s *Supervisor) getContainers(t *GetContainersTask) error {
|
||||||
|
|
||||||
if t.ID != "" {
|
if t.ID != "" {
|
||||||
ci := s.containers[t.ID]
|
ci, ok := s.containers[t.ID]
|
||||||
if ci == nil {
|
if !ok {
|
||||||
return ErrContainerNotFound
|
return ErrContainerNotFound
|
||||||
}
|
}
|
||||||
t.Containers = append(t.Containers, ci.container)
|
t.Containers = append(t.Containers, ci.container)
|
||||||
|
|
||||||
return nil
|
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
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue