|
123456789101112131415161718192021222324252627282930313233343536 |
- package bucket
-
- import (
- "fmt"
-
- "github.com/spf13/cobra"
- cliapi "gitlink.org.cn/cloudream/jcs-pub/client/sdk/api/v1"
- "gitlink.org.cn/cloudream/jcs-pub/jcsctl/cmd"
- )
-
- func init() {
- var opt newOpt
- cmd := cobra.Command{
- Use: "new <bucket_name>",
- Args: cobra.ExactArgs(1),
- RunE: func(c *cobra.Command, args []string) error {
- ctx := cmd.GetCmdCtx(c)
- return new(c, ctx, opt, args)
- },
- }
- BucketCmd.AddCommand(&cmd)
- }
-
- type newOpt struct {
- }
-
- func new(c *cobra.Command, ctx *cmd.CommandContext, opt newOpt, args []string) error {
- resp, err := ctx.Client.Bucket().Create(cliapi.BucketCreate{
- Name: args[0],
- })
- if err != nil {
- return fmt.Errorf("create bucket %v: %v", args[0], err)
- }
- printOneBucket(resp.Bucket)
- return nil
- }
|