Move service to execution package

Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Michael Crosby 2016-12-05 14:33:31 -08:00
parent c857213b4c
commit bde30191f4
4 changed files with 8 additions and 30 deletions

View File

@ -13,7 +13,7 @@ import (
"github.com/Sirupsen/logrus"
"github.com/docker/containerd"
api "github.com/docker/containerd/api/execution"
"github.com/docker/containerd/services/execution"
"github.com/docker/containerd/execution"
// metrics "github.com/docker/go-metrics"
"github.com/urfave/cli"
)

View File

@ -1,13 +0,0 @@
package executors
import "github.com/docker/containerd/execution"
var executors = make(map[string]func() execution.Executor)
func Register(name string, e func() execution.Executor) {
executors[name] = e
}
func Get(name string) func() execution.Executor {
return executors[name]
}

View File

@ -10,16 +10,10 @@ import (
"github.com/crosbymichael/go-runc"
"github.com/docker/containerd/execution"
"github.com/docker/containerd/executors"
)
var ErrRootEmpty = errors.New("oci: runtime root cannot be an empty string")
func init() {
executors.Register("oci", New)
executors.Register("runc", New)
}
func New(root string) *OCIRuntime {
return &OCIRuntime{
root: root,

View File

@ -4,35 +4,32 @@ import (
"fmt"
api "github.com/docker/containerd/api/execution"
"github.com/docker/containerd/execution"
"github.com/docker/containerd/execution/executors"
google_protobuf "github.com/golang/protobuf/ptypes/empty"
"github.com/opencontainers/runtime-spec/specs-go"
"golang.org/x/net/context"
)
type Opts struct {
type ServiceOpts struct {
Root string
Runtime string
}
func New(o Opts) (*Service, error) {
executor := executors.Get(o.Runtime)()
func New(opts ServiceOpts, executor Executor) (*Service, error) {
return &Service{
o: o,
o: opts,
executor: executor,
}, nil
}
type Service struct {
o Opts
executor execution.Executor
o ServiceOpts
executor Executor
}
func (s *Service) Create(ctx context.Context, r *api.CreateContainerRequest) (*api.CreateContainerResponse, error) {
// TODO: write io and bundle path to dir
// TODO: open IOs
container, err := s.executor.Create(r.ID, execution.CreateOpts{
container, err := s.executor.Create(r.ID, CreateOpts{
Bundle: r.BundlePath,
// Stdin: r.Stdin,
// Stdout: r.Stdout,
@ -111,7 +108,7 @@ func (s *Service) StartProcess(ctx context.Context, r *api.StartProcessRequest)
// TODO: generate spec
var spec specs.Process
// TODO: open IOs
process, err := s.executor.StartProcess(container, execution.CreateProcessOpts{
process, err := s.executor.StartProcess(container, CreateProcessOpts{
Spec: spec,
// Stdin: r.Stdin,
// Stdout: r.Stdout,