You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

new.go 748 B

123456789101112131415161718192021222324252627282930313233343536
  1. package bucket
  2. import (
  3. "fmt"
  4. "github.com/spf13/cobra"
  5. cliapi "gitlink.org.cn/cloudream/jcs-pub/client/sdk/api/v1"
  6. "gitlink.org.cn/cloudream/jcs-pub/jcsctl/cmd"
  7. )
  8. func init() {
  9. var opt newOpt
  10. cmd := cobra.Command{
  11. Use: "new <bucket_name>",
  12. Args: cobra.ExactArgs(1),
  13. RunE: func(c *cobra.Command, args []string) error {
  14. ctx := cmd.GetCmdCtx(c)
  15. return new(c, ctx, opt, args)
  16. },
  17. }
  18. BucketCmd.AddCommand(&cmd)
  19. }
  20. type newOpt struct {
  21. }
  22. func new(c *cobra.Command, ctx *cmd.CommandContext, opt newOpt, args []string) error {
  23. resp, err := ctx.Client.Bucket().Create(cliapi.BucketCreate{
  24. Name: args[0],
  25. })
  26. if err != nil {
  27. return fmt.Errorf("create bucket %v: %v", args[0], err)
  28. }
  29. printOneBucket(resp.Bucket)
  30. return nil
  31. }

本项目旨在将云际存储公共基础设施化,使个人及企业可低门槛使用高效的云际存储服务(安装开箱即用云际存储客户端即可,无需关注其他组件的部署),同时支持用户灵活便捷定制云际存储的功能细节。