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-02-03 14:41:28 +00:00
|
|
|
func (s *Server) getContainerFromRequest(containerID string) (*oci.Container, error) {
|
|
|
|
if containerID == "" {
|
2016-11-22 22:23:01 +00:00
|
|
|
return nil, fmt.Errorf("container ID should not be empty")
|
|
|
|
}
|
|
|
|
|
2017-02-03 14:41:28 +00:00
|
|
|
containerID, err := s.ctrIDIndex.Get(containerID)
|
2016-11-22 22:23:01 +00:00
|
|
|
if err != nil {
|
2017-02-03 14:41:28 +00:00
|
|
|
return nil, fmt.Errorf("container with ID starting with %s not found: %v", containerID, 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
|
|
|
|
}
|