diff options
| author | Chris Lu <chris.lu@gmail.com> | 2019-05-30 09:47:54 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2019-05-30 09:47:54 -0700 |
| commit | 40ca2f2903c2b95aa4dd2101598f0dbdd2024d07 (patch) | |
| tree | 1171a40d065f457a85133b08353e29970f06ccc9 /weed/shell/command_collection_delete.go | |
| parent | 1d111d6ce80727f2c0a25b36b85102d5cb5ae612 (diff) | |
| download | seaweedfs-40ca2f2903c2b95aa4dd2101598f0dbdd2024d07.tar.xz seaweedfs-40ca2f2903c2b95aa4dd2101598f0dbdd2024d07.zip | |
add collection.delete
Diffstat (limited to 'weed/shell/command_collection_delete.go')
| -rw-r--r-- | weed/shell/command_collection_delete.go | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/weed/shell/command_collection_delete.go b/weed/shell/command_collection_delete.go new file mode 100644 index 000000000..e3356aba4 --- /dev/null +++ b/weed/shell/command_collection_delete.go @@ -0,0 +1,51 @@ +package shell + +import ( + "context" + "fmt" + "github.com/chrislusf/seaweedfs/weed/pb/master_pb" + "io" +) + +func init() { + commands = append(commands, &commandCollectionDelete{}) +} + +type commandCollectionDelete struct { +} + +func (c *commandCollectionDelete) Name() string { + return "collection.delete" +} + +func (c *commandCollectionDelete) Help() string { + return `delete specified collection + + collection.delete <collection_name> + +` +} + +func (c *commandCollectionDelete) Do(args []string, commandEnv *commandEnv, writer io.Writer) (err error) { + + if len(args) == 0 { + return nil + } + + collectionName := args[0] + + ctx := context.Background() + err = commandEnv.masterClient.WithClient(ctx, func(client master_pb.SeaweedClient) error { + _, err = client.CollectionDelete(ctx, &master_pb.CollectionDeleteRequest{ + Name: collectionName, + }) + return err + }) + if err != nil { + return + } + + fmt.Fprintf(writer, "collection %s is deleted.\n", collectionName) + + return nil +} |
