2016-11-22 22:23:01 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/kubernetes-incubator/cri-o/oci"
|
|
|
|
)
|
|
|
|
|
2017-05-28 17:33:10 +00:00
|
|
|
func (s *Server) getContainerFromRequest(cid string) (*oci.Container, error) {
|
|
|
|
if cid == "" {
|
2016-11-22 22:23:01 +00:00
|
|
|
return nil, fmt.Errorf("container ID should not be empty")
|
|
|
|
}
|
|
|
|
|
2017-07-17 12:25:32 +00:00
|
|
|
containerID, err := s.CtrIDIndex().Get(cid)
|
2016-11-22 22:23:01 +00:00
|
|
|
if err != nil {
|
2017-05-28 17:33:10 +00:00
|
|
|
return nil, fmt.Errorf("container with ID starting with %s not found: %v", cid, err)
|
2016-11-22 22:23:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
c := s.state.containers.Get(containerID)
|
|
|
|
if c == nil {
|
|
|
|
return nil, fmt.Errorf("specified container not found: %s", containerID)
|
|
|
|
}
|
|
|
|
return c, nil
|
|
|
|
}
|