-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy paths3.go
More file actions
39 lines (35 loc) · 1.58 KB
/
s3.go
File metadata and controls
39 lines (35 loc) · 1.58 KB
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
package config
import (
"github.com/docker/distribution/registry/storage/driver"
"github.com/docker/distribution/registry/storage/driver/factory"
// this blank import is used to register the S3 driver with the storage driver factory
_ "github.com/docker/distribution/registry/storage/driver/s3-aws"
)
// S3 is the Config implementation for the S3 client
type S3 struct {
AccessKeyFile string `envconfig:"ACCESS_KEY_FILE" default:"/var/run/secrets/deis/objectstore/creds/accesskey"`
SecretKeyFile string `envconfig:"SECRET_KEY_FILE" default:"/var/run/secrets/deis/objectstore/creds/secretkey"`
RegionFile string `envconfig:"REGION_FILE" default:"/var/run/secrets/deis/objectstore/creds/region"`
EndpointFile string `envconfig:"ENDPOINT_FILE" default:"/var/run/secrets/deis/objectstore/creds/endpoint"`
BucketFile string `envconfig:"BUCKET_FILE" default:"/var/run/secrets/deis/objectstore/creds/bucket"`
}
// CreateDriver is the Config interface implementation
func (s S3) CreateDriver() (driver.StorageDriver, error) {
files, err := readFiles(true, s.AccessKeyFile, s.SecretKeyFile, s.RegionFile, s.EndpointFile, s.BucketFile)
if err != nil {
return nil, err
}
key, secret, region, endpoint, bucket := files[0], files[1], files[2], files[3], files[4]
params := map[string]interface{}{
"accesskey": key,
"secretkey": secret,
"region": region,
"regionendpoint": endpoint,
"bucket": bucket,
}
return factory.Create("s3aws", params)
}
// String is the fmt.Stringer interface implementation
func (s S3) String() string {
return S3StorageType.String()
}