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

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

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