vc: Use map built-in accessor to find container in Sandbox#GetContainer

Fixes #2289

Signed-off-by: Ted Yu <yuzhihong@gmail.com>
This commit is contained in:
Ted Yu 2019-11-29 07:17:13 -08:00
parent d054556f60
commit 38224e8b7b

View File

@ -279,10 +279,8 @@ func (s *Sandbox) GetAllContainers() []VCContainer {
// GetContainer returns the container named by the containerID.
func (s *Sandbox) GetContainer(containerID string) VCContainer {
for id, c := range s.containers {
if id == containerID {
return c
}
if c, ok := s.containers[containerID]; ok {
return c
}
return nil
}