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.

bucket.go 1.3 kB

7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
7 months ago
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. package cmdline
  2. import (
  3. "fmt"
  4. "time"
  5. "github.com/jedib0t/go-pretty/v6/table"
  6. cdssdk "gitlink.org.cn/cloudream/storage2/client/types"
  7. )
  8. func BucketListUserBuckets(ctx CommandContext) error {
  9. buckets, err := ctx.Cmdline.Svc.BucketSvc().GetUserBuckets()
  10. if err != nil {
  11. return err
  12. }
  13. fmt.Printf("Find %d buckets for user %d:\n", len(buckets))
  14. tb := table.NewWriter()
  15. tb.AppendHeader(table.Row{"ID", "Name"})
  16. for _, bucket := range buckets {
  17. tb.AppendRow(table.Row{bucket.BucketID, bucket.Name})
  18. }
  19. fmt.Print(tb.Render())
  20. return nil
  21. }
  22. func BucketCreateBucket(ctx CommandContext, bucketName string) error {
  23. bucketID, err := ctx.Cmdline.Svc.BucketSvc().CreateBucket(bucketName, time.Now())
  24. if err != nil {
  25. return err
  26. }
  27. fmt.Printf("Create bucket %v success, id: %v", bucketName, bucketID)
  28. return nil
  29. }
  30. func BucketDeleteBucket(ctx CommandContext, bucketID cdssdk.BucketID) error {
  31. err := ctx.Cmdline.Svc.BucketSvc().DeleteBucket(bucketID)
  32. if err != nil {
  33. return err
  34. }
  35. fmt.Printf("Delete bucket %d success ", bucketID)
  36. return nil
  37. }
  38. func init() {
  39. commands.MustAdd(BucketListUserBuckets, "bucket", "ls")
  40. commands.MustAdd(BucketCreateBucket, "bucket", "new")
  41. commands.MustAdd(BucketDeleteBucket, "bucket", "delete")
  42. }

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