server: split sandboxes actions
Signed-off-by: Antonio Murdaca <runcom@redhat.com>
This commit is contained in:
parent
4447207cf1
commit
ebe2ea0dba
8 changed files with 602 additions and 549 deletions
29
server/container.go
Normal file
29
server/container.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package server
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"github.com/kubernetes-incubator/cri-o/oci"
|
||||
)
|
||||
|
||||
type containerRequest interface {
|
||||
GetContainerId() string
|
||||
}
|
||||
|
||||
func (s *Server) getContainerFromRequest(req containerRequest) (*oci.Container, error) {
|
||||
ctrID := req.GetContainerId()
|
||||
if ctrID == "" {
|
||||
return nil, fmt.Errorf("container ID should not be empty")
|
||||
}
|
||||
|
||||
containerID, err := s.ctrIDIndex.Get(ctrID)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("container with ID starting with %s not found: %v", ctrID, err)
|
||||
}
|
||||
|
||||
c := s.state.containers.Get(containerID)
|
||||
if c == nil {
|
||||
return nil, fmt.Errorf("specified container not found: %s", containerID)
|
||||
}
|
||||
return c, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue