2016-11-22 23:23:01 +01:00
|
|
|
package server
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
|
|
|
"github.com/kubernetes-incubator/cri-o/oci"
|
|
|
|
)
|
|
|
|
|
2016-11-12 04:15:59 +01:00
|
|
|
const (
|
|
|
|
// containerTypeSandbox represents a pod sandbox container
|
|
|
|
containerTypeSandbox = "sandbox"
|
|
|
|
// containerTypeContainer represents a container running within a pod
|
|
|
|
containerTypeContainer = "container"
|
|
|
|
)
|
|
|
|
|
2017-02-03 15:41:28 +01:00
|
|
|
func (s *Server) getContainerFromRequest(containerID string) (*oci.Container, error) {
|
|
|
|
if containerID == "" {
|
2016-11-22 23:23:01 +01:00
|
|
|
return nil, fmt.Errorf("container ID should not be empty")
|
|
|
|
}
|
|
|
|
|
2017-02-03 15:41:28 +01:00
|
|
|
containerID, err := s.ctrIDIndex.Get(containerID)
|
2016-11-22 23:23:01 +01:00
|
|
|
if err != nil {
|
2017-02-03 15:41:28 +01:00
|
|
|
return nil, fmt.Errorf("container with ID starting with %s not found: %v", containerID, err)
|
2016-11-22 23:23:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
c := s.state.containers.Get(containerID)
|
|
|
|
if c == nil {
|
|
|
|
return nil, fmt.Errorf("specified container not found: %s", containerID)
|
|
|
|
}
|
|
|
|
return c, nil
|
|
|
|
}
|