64ad902480
Move non-kubernetes-dependent portions of server struct to libkpod. So far, only the struct fields have been moved and not their dependent functions Signed-off-by: Ryan Cole <rcyoalne@gmail.com>
24 lines
546 B
Go
24 lines
546 B
Go
package server
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/kubernetes-incubator/cri-o/oci"
|
|
)
|
|
|
|
func (s *Server) getContainerFromRequest(cid string) (*oci.Container, error) {
|
|
if cid == "" {
|
|
return nil, fmt.Errorf("container ID should not be empty")
|
|
}
|
|
|
|
containerID, err := s.CtrIDIndex().Get(cid)
|
|
if err != nil {
|
|
return nil, fmt.Errorf("container with ID starting with %s not found: %v", cid, err)
|
|
}
|
|
|
|
c := s.state.containers.Get(containerID)
|
|
if c == nil {
|
|
return nil, fmt.Errorf("specified container not found: %s", containerID)
|
|
}
|
|
return c, nil
|
|
}
|