mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2024-01-19 02:48:24 +00:00
cloud drive: add list buckets
This commit is contained in:
parent
fbfc90fd1e
commit
83cd0fc739
|
@ -205,6 +205,7 @@ func (az *azureRemoteStorageClient) UpdateFileMetadata(loc *remote_pb.RemoteStor
|
|||
|
||||
return
|
||||
}
|
||||
|
||||
func (az *azureRemoteStorageClient) DeleteFile(loc *remote_pb.RemoteStorageLocation) (err error) {
|
||||
key := loc.Path[1:]
|
||||
containerURL := az.serviceURL.NewContainerURL(loc.Bucket)
|
||||
|
@ -214,3 +215,17 @@ func (az *azureRemoteStorageClient) DeleteFile(loc *remote_pb.RemoteStorageLocat
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (az *azureRemoteStorageClient) ListBuckets() (buckets []*remote_storage.Bucket, err error) {
|
||||
resp, err := az.ListBuckets()
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("list buckets: %v", err)
|
||||
}
|
||||
for _, b := range resp {
|
||||
buckets = append(buckets, &remote_storage.Bucket{
|
||||
Name: b.Name,
|
||||
CreatedAt: b.CreatedAt,
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
|
@ -184,3 +184,7 @@ func (gcs *gcsRemoteStorageClient) DeleteFile(loc *remote_pb.RemoteStorageLocati
|
|||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (gcs *gcsRemoteStorageClient) ListBuckets() (buckets []*remote_storage.Bucket, err error) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -170,9 +170,14 @@ func (c *hdfsRemoteStorageClient) UpdateFileMetadata(loc *remote_pb.RemoteStorag
|
|||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
func (c *hdfsRemoteStorageClient) DeleteFile(loc *remote_pb.RemoteStorageLocation) (err error) {
|
||||
if err = c.client.Remove(loc.Path); err != nil {
|
||||
return fmt.Errorf("hdfs delete %s: %v", loc.Path, err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
func (c *hdfsRemoteStorageClient) ListBuckets() (buckets []*remote_storage.Bucket, err error) {
|
||||
return
|
||||
}
|
||||
|
|
|
@ -8,6 +8,7 @@ import (
|
|||
"io"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
)
|
||||
|
||||
func ParseLocationName(remote string) (locationName string) {
|
||||
|
@ -65,6 +66,11 @@ func FormatLocation(loc *remote_pb.RemoteStorageLocation) string {
|
|||
|
||||
type VisitFunc func(dir string, name string, isDirectory bool, remoteEntry *filer_pb.RemoteEntry) error
|
||||
|
||||
type Bucket struct {
|
||||
Name string
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
type RemoteStorageClient interface {
|
||||
Traverse(loc *remote_pb.RemoteStorageLocation, visitFn VisitFunc) error
|
||||
ReadFile(loc *remote_pb.RemoteStorageLocation, offset int64, size int64) (data []byte, err error)
|
||||
|
@ -73,6 +79,7 @@ type RemoteStorageClient interface {
|
|||
WriteFile(loc *remote_pb.RemoteStorageLocation, entry *filer_pb.Entry, reader io.Reader) (remoteEntry *filer_pb.RemoteEntry, err error)
|
||||
UpdateFileMetadata(loc *remote_pb.RemoteStorageLocation, oldEntry *filer_pb.Entry, newEntry *filer_pb.Entry) (err error)
|
||||
DeleteFile(loc *remote_pb.RemoteStorageLocation) (err error)
|
||||
ListBuckets() ([]*Bucket, error)
|
||||
}
|
||||
|
||||
type RemoteStorageClientMaker interface {
|
||||
|
|
|
@ -234,3 +234,17 @@ func (s *s3RemoteStorageClient) DeleteFile(loc *remote_pb.RemoteStorageLocation)
|
|||
})
|
||||
return
|
||||
}
|
||||
|
||||
func (s *s3RemoteStorageClient) ListBuckets() (buckets []*remote_storage.Bucket, err error) {
|
||||
resp, err := s.conn.ListBuckets(&s3.ListBucketsInput{})
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("list buckets: %v", err)
|
||||
}
|
||||
for _, b := range resp.Buckets {
|
||||
buckets = append(buckets, &remote_storage.Bucket{
|
||||
Name: *b.Name,
|
||||
CreatedAt: *b.CreationDate,
|
||||
})
|
||||
}
|
||||
return
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue