/
purefb.go
49 lines (40 loc) · 1.28 KB
/
purefb.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package purefb
import (
"github.com/aws/aws-sdk-go/aws"
"github.com/libopenstorage/openstorage/bucket"
"github.com/libopenstorage/openstorage/bucket/drivers/s3"
)
// PureFBDriver represents a way to interact with a Pure FlashBlade
// object storage backend via the AWS SDK
type PureFBDriver struct {
*s3.S3Driver
AccessKeyID string
SecretAccessKey string
}
// New create a new PureFBDriver instance
func New(cfg *aws.Config, accessKeyID, secretAccessKey string) (*PureFBDriver, error) {
s3Driver, err := s3.New(cfg)
if err != nil {
return nil, err
}
return &PureFBDriver{
S3Driver: s3Driver,
AccessKeyID: accessKeyID,
SecretAccessKey: secretAccessKey,
}, nil
}
// GrantBucketAccess gives admin access to a bucket
func (p *PureFBDriver) GrantBucketAccess(id string, accountName string, accessPolicy string) (string, *bucket.BucketAccessCredentials, error) {
return "fb-admin-account", &bucket.BucketAccessCredentials{
AccessKeyId: p.AccessKeyID,
SecretAccessKey: p.SecretAccessKey,
}, nil
}
// RevokeBucketAccess is a no-op for admin access to a bucket
func (p *PureFBDriver) RevokeBucketAccess(id string, accountId string) error {
return nil
}
// String returns the driver name for Pure FlashBlade
func (p *PureFBDriver) String() string {
return "PureFBDriver"
}