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>
55 lines
1.1 KiB
Go
55 lines
1.1 KiB
Go
package main
|
|
|
|
import (
|
|
contextpkg "context"
|
|
"fmt"
|
|
|
|
"github.com/docker/containerd/log"
|
|
digest "github.com/opencontainers/go-digest"
|
|
"github.com/urfave/cli"
|
|
)
|
|
|
|
var deleteCommand = cli.Command{
|
|
Name: "delete",
|
|
Aliases: []string{"del"},
|
|
Usage: "permanently delete one or more blobs.",
|
|
ArgsUsage: "[flags] [<digest>, ...]",
|
|
Description: `Delete one or more blobs permanently. Successfully deleted
|
|
blobs are printed to stdout.`,
|
|
Flags: []cli.Flag{},
|
|
Action: func(context *cli.Context) error {
|
|
var (
|
|
ctx = contextpkg.Background()
|
|
args = []string(context.Args())
|
|
exitError error
|
|
)
|
|
|
|
cs, err := resolveContentStore(context)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
for _, arg := range args {
|
|
dgst, err := digest.Parse(arg)
|
|
if err != nil {
|
|
if exitError == nil {
|
|
exitError = err
|
|
}
|
|
log.G(ctx).WithError(err).Errorf("could not delete %v", dgst)
|
|
continue
|
|
}
|
|
|
|
if err := cs.Delete(dgst); err != nil {
|
|
if exitError == nil {
|
|
exitError = err
|
|
}
|
|
log.G(ctx).WithError(err).Errorf("could not delete %v", dgst)
|
|
continue
|
|
}
|
|
|
|
fmt.Println(dgst)
|
|
}
|
|
|
|
return exitError
|
|
},
|
|
}
|