
The split between provider and ingester was a long standing division reflecting the client-side use cases. For the most part, we were differentiating these for the algorithms that operate them, but it made instantation and use of the types challenging. On the server-side, this distinction is generally less important. This change unifies these types and in the process we get a few benefits. The first is that we now completely access the content store over GRPC. This was the initial intent and we have now satisfied this goal completely. There are a few issues around listing content and getting status, but we resolve these with simple streaming and regexp filters. More can probably be done to polish this but the result is clean. Several other content-oriented methods were polished in the process of unification. We have now properly seperated out the `Abort` method to cancel ongoing or stalled ingest processes. We have also replaced the `Active` method with a single status method. The transition went extremely smoothly. Once the clients were updated to use the new methods, every thing worked as expected on the first compile. Signed-off-by: Stephen J Day <stephen.day@docker.com>
70 lines
1.5 KiB
Go
70 lines
1.5 KiB
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
"text/tabwriter"
|
|
"time"
|
|
|
|
"github.com/containerd/containerd/content"
|
|
"github.com/containerd/containerd/log"
|
|
units "github.com/docker/go-units"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var listCommand = cli.Command{
|
|
Name: "list",
|
|
Aliases: []string{"ls"},
|
|
Usage: "list all blobs in the store.",
|
|
ArgsUsage: "[flags] [<prefix>, ...]",
|
|
Description: `List blobs in the content store.`,
|
|
Flags: []cli.Flag{
|
|
cli.BoolFlag{
|
|
Name: "quiet, q",
|
|
Usage: "print only the blob digest",
|
|
},
|
|
},
|
|
Action: func(context *cli.Context) error {
|
|
var (
|
|
quiet = context.Bool("quiet")
|
|
args = []string(context.Args())
|
|
)
|
|
ctx, cancel := appContext()
|
|
defer cancel()
|
|
|
|
cs, err := resolveContentStore(context)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
if len(args) > 0 {
|
|
// TODO(stevvooe): Implement selection of a few blobs. Not sure
|
|
// what kind of efficiency gains we can actually get here.
|
|
log.G(ctx).Warnf("args ignored; need to implement matchers")
|
|
}
|
|
|
|
var walkFn content.WalkFunc
|
|
if quiet {
|
|
walkFn = func(info content.Info) error {
|
|
fmt.Println(info.Digest)
|
|
return nil
|
|
}
|
|
} else {
|
|
tw := tabwriter.NewWriter(os.Stdout, 1, 8, 1, '\t', 0)
|
|
defer tw.Flush()
|
|
|
|
fmt.Fprintln(tw, "DIGEST\tSIZE\tAGE")
|
|
walkFn = func(info content.Info) error {
|
|
fmt.Fprintf(tw, "%s\t%s\t%s\n",
|
|
info.Digest,
|
|
units.HumanSize(float64(info.Size)),
|
|
units.HumanDuration(time.Since(info.CommittedAt)))
|
|
return nil
|
|
}
|
|
|
|
}
|
|
|
|
return cs.Walk(ctx, walkFn)
|
|
},
|
|
}
|