621164bc84
After iterating on the GRPC API, the changes required for the actual implementation are now included in the content store. The begin change is the move to a single, atomic `Ingester.Writer` method for locking content ingestion on a key. From this, comes several new interface definitions. The main benefit here is the clarification between `Status` and `Info` that came out of the GPRC API. `Status` tells the status of a write, whereas `Info` is for querying metadata about various blobs. Signed-off-by: Stephen J Day <stephen.day@docker.com>
53 lines
1.1 KiB
Go
53 lines
1.1 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] [<key>, ...]",
|
|
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 {
|
|
cs, err := resolveContentStore(context)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
active, err := cs.Active()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
tw := tabwriter.NewWriter(os.Stdout, 1, 8, 1, '\t', 0)
|
|
fmt.Fprintln(tw, "REF\tSIZE\tAGE")
|
|
for _, active := range active {
|
|
fmt.Fprintf(tw, "%s\t%s\t%s\n",
|
|
active.Ref,
|
|
units.HumanSize(float64(active.Offset)),
|
|
units.HumanDuration(time.Since(active.StartedAt)))
|
|
}
|
|
tw.Flush()
|
|
|
|
return nil
|
|
},
|
|
}
|