Files
containerd/cmd/dist/active.go
Derek McGowan b6d58f63a8 Support for ingest namespacing
Move content status to list statuses and add single status
to interface.
Updates API to support list statuses and status
Updates snapshot key creation to be generic

Signed-off-by: Derek McGowan <derek@mcgstyle.net>
2017-07-11 11:11:10 -07:00

60 lines
1.2 KiB
Go

package main
import (
"fmt"
"os"
"text/tabwriter"
"time"
units "github.com/docker/go-units"
"github.com/urfave/cli"
)
var activeCommand = cli.Command{
Name: "active",
Usage: "display active transfers.",
ArgsUsage: "[flags] [<regexp>]",
Description: `Display the ongoing transfers.`,
Flags: []cli.Flag{
cli.DurationFlag{
Name: "timeout, t",
Usage: "total timeout for fetch",
EnvVar: "CONTAINERD_FETCH_TIMEOUT",
},
cli.StringFlag{
Name: "root",
Usage: "path to content store root",
Value: "/tmp/content", // TODO(stevvooe): for now, just use the PWD/.content
},
},
Action: func(context *cli.Context) error {
var (
match = context.Args().First()
)
ctx, cancel := appContext(context)
defer cancel()
cs, err := resolveContentStore(context)
if err != nil {
return err
}
active, err := cs.ListStatuses(ctx, match)
if err != nil {
return err
}
tw := tabwriter.NewWriter(os.Stdout, 1, 8, 1, '\t', 0)
fmt.Fprintln(tw, "REF\tSIZE\tAGE\t")
for _, active := range active {
fmt.Fprintf(tw, "%s\t%s\t%s\t\n",
active.Ref,
units.HumanSize(float64(active.Offset)),
units.HumanDuration(time.Since(active.StartedAt)))
}
return tw.Flush()
},
}