2016-11-22 22:23:01 +00:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/kubernetes-incubator/cri-o/oci"
|
|
|
|
)
|
|
|
|
|
2016-11-12 03:15:59 +00:00
|
|
|
const (
|
|
|
|
// containerTypeSandbox represents a pod sandbox container
|
|
|
|
containerTypeSandbox = "sandbox"
|
|
|
|
// containerTypeContainer represents a container running within a pod
|
|
|
|
containerTypeContainer = "container"
|
|
|
|
)
|
|
|
|
|
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-05-28 17:33:10 +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
|
|
|
|
}
|