Initial windows runtime work
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
40
cmd/ctr/exec_windows.go
Normal file
40
cmd/ctr/exec_windows.go
Normal file
@@ -0,0 +1,40 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/containerd/containerd/api/services/execution"
|
||||
protobuf "github.com/gogo/protobuf/types"
|
||||
specs "github.com/opencontainers/runtime-spec/specs-go"
|
||||
"github.com/urfave/cli"
|
||||
)
|
||||
|
||||
func newExecRequest(context *cli.Context, tmpDir, id string) (*execution.ExecRequest, error) {
|
||||
process := specs.Process{
|
||||
Args: context.Args(),
|
||||
Terminal: context.Bool("tty"),
|
||||
Cwd: context.String("cwd"),
|
||||
}
|
||||
data, err := json.Marshal(process)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
now := time.Now().UnixNano()
|
||||
request := &execution.ExecRequest{
|
||||
ID: id,
|
||||
Spec: &protobuf.Any{
|
||||
TypeUrl: specs.Version,
|
||||
Value: data,
|
||||
},
|
||||
Terminal: context.Bool("tty"),
|
||||
Stdin: fmt.Sprintf(`%s\ctr-%s-stdin-`, pipeRoot, id, now),
|
||||
Stdout: fmt.Sprintf(`%s\ctr-%s-stdout-`, pipeRoot, id, now),
|
||||
}
|
||||
if !request.Terminal {
|
||||
request.Stderr = fmt.Sprintf(`%s\ctr-%s-stderr-`, pipeRoot, id, now)
|
||||
}
|
||||
|
||||
return request, nil
|
||||
}
|
Reference in New Issue
Block a user