ctr: add remove subcommand to snapshot
Signed-off-by: Kenfe-Mickael Laventure <mickael.laventure@gmail.com>
This commit is contained in:
parent
5a02ae929c
commit
de632b1084
@ -2,7 +2,6 @@ package main
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"errors"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"text/tabwriter"
|
"text/tabwriter"
|
||||||
@ -10,6 +9,7 @@ import (
|
|||||||
"github.com/containerd/containerd/progress"
|
"github.com/containerd/containerd/progress"
|
||||||
"github.com/containerd/containerd/rootfs"
|
"github.com/containerd/containerd/rootfs"
|
||||||
"github.com/containerd/containerd/snapshot"
|
"github.com/containerd/containerd/snapshot"
|
||||||
|
"github.com/pkg/errors"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -20,6 +20,7 @@ var snapshotCommand = cli.Command{
|
|||||||
archiveSnapshotCommand,
|
archiveSnapshotCommand,
|
||||||
listSnapshotCommand,
|
listSnapshotCommand,
|
||||||
usageSnapshotCommand,
|
usageSnapshotCommand,
|
||||||
|
removeSnapshotCommand,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -165,3 +166,30 @@ var usageSnapshotCommand = cli.Command{
|
|||||||
return tw.Flush()
|
return tw.Flush()
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var removeSnapshotCommand = cli.Command{
|
||||||
|
Name: "remove",
|
||||||
|
Aliases: []string{"rm"},
|
||||||
|
ArgsUsage: "id [id] ...",
|
||||||
|
Usage: "remove snapshots",
|
||||||
|
Action: func(clicontext *cli.Context) error {
|
||||||
|
ctx, cancel := appContext(clicontext)
|
||||||
|
defer cancel()
|
||||||
|
|
||||||
|
client, err := newClient(clicontext)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
snapshotter := client.SnapshotService()
|
||||||
|
|
||||||
|
for _, id := range clicontext.Args() {
|
||||||
|
err = snapshotter.Remove(ctx, id)
|
||||||
|
if err != nil {
|
||||||
|
return errors.Wrapf(err, "failed to remove %q", id)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return nil
|
||||||
|
},
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user