Move WithExit to runcopts package

Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
Signed-off-by: Michael Crosby <crosbymichael@gmail.com>
This commit is contained in:
Kenfe-Mickael Laventure
2017-06-29 15:44:47 -07:00
committed by Michael Crosby
parent 124f430d44
commit ccbe92dc08
3 changed files with 33 additions and 55 deletions

View File

@@ -1,3 +1,33 @@
package runcopts
import (
"path/filepath"
tasks "github.com/containerd/containerd/api/services/tasks/v1"
"github.com/gogo/protobuf/proto"
protobuf "github.com/gogo/protobuf/types"
)
const URIBase = "types.containerd.io/linux/runc"
func WithExit(r *tasks.CheckpointTaskRequest) error {
a, err := marshal(&CheckpointOptions{
Exit: true,
}, "CheckpointOptions")
if err != nil {
return err
}
r.Options = a
return nil
}
func marshal(m proto.Message, name string) (*protobuf.Any, error) {
data, err := proto.Marshal(m)
if err != nil {
return nil, err
}
return &protobuf.Any{
TypeUrl: filepath.Join(URIBase, name),
Value: data,
}, nil
}