Support --log-uri for exec subcommand
@@ -18,6 +18,7 @@ package tasks
import (
"errors"
+ "net/url"
"github.com/containerd/console"
"github.com/containerd/containerd/cio"
@@ -53,6 +54,10 @@ var execCommand = cli.Command{
Name: "fifo-dir",
Usage: "directory used for storing IO FIFOs",
},
+ cli.StringFlag{
+ Name: "log-uri",
+ Usage: "log uri for custom shim logging",
+ },
},
Action: func(context *cli.Context) error {
var (
@@ -86,11 +91,22 @@ var execCommand = cli.Command{
pspec.Terminal = tty
pspec.Args = args
+ var ioCreator cio.Creator
+
+ if logURI := context.String("log-uri"); logURI != "" {
+ uri, err := url.Parse(logURI)
+ if err != nil {
+ return err
+ }
+ ioCreator = cio.LogURI(uri)
+ } else {
cioOpts := []cio.Opt{cio.WithStdio, cio.WithFIFODir(context.String("fifo-dir"))}
if tty {
cioOpts = append(cioOpts, cio.WithTerminal)
}
- ioCreator := cio.NewCreator(cioOpts...)
+ ioCreator = cio.NewCreator(cioOpts...)
+ }
+
process, err := task.Exec(ctx, context.String("exec-id"), pspec, ioCreator)
if err != nil {
return err
