Added support to specifiy custom endpoint
Signed-off-by: Keerthan Reddy Mala <keerthan.mala@gmail.com>master
							parent
							
								
									46b2c3fadf
								
							
						
					
					
						commit
						2be1b4ef4f
					
				| 
						 | 
					@ -90,6 +90,7 @@ information about each option that appears later in this page.
 | 
				
			||||||
        accesskey: awsaccesskey
 | 
					        accesskey: awsaccesskey
 | 
				
			||||||
        secretkey: awssecretkey
 | 
					        secretkey: awssecretkey
 | 
				
			||||||
        region: us-west-1
 | 
					        region: us-west-1
 | 
				
			||||||
 | 
					        regionendpoint: http://myobjects.local
 | 
				
			||||||
        bucket: bucketname
 | 
					        bucket: bucketname
 | 
				
			||||||
        encrypt: true
 | 
					        encrypt: true
 | 
				
			||||||
        secure: true
 | 
					        secure: true
 | 
				
			||||||
| 
						 | 
					@ -358,6 +359,7 @@ Permitted values are `error`, `warn`, `info` and `debug`. The default is
 | 
				
			||||||
        accesskey: awsaccesskey
 | 
					        accesskey: awsaccesskey
 | 
				
			||||||
        secretkey: awssecretkey
 | 
					        secretkey: awssecretkey
 | 
				
			||||||
        region: us-west-1
 | 
					        region: us-west-1
 | 
				
			||||||
 | 
					        regionendpoint: http://myobjects.local
 | 
				
			||||||
        bucket: bucketname
 | 
					        bucket: bucketname
 | 
				
			||||||
        encrypt: true
 | 
					        encrypt: true
 | 
				
			||||||
        secure: true
 | 
					        secure: true
 | 
				
			||||||
| 
						 | 
					@ -435,7 +437,7 @@ You must configure one backend; if you configure more, the registry returns an e
 | 
				
			||||||
  </tr>
 | 
					  </tr>
 | 
				
			||||||
  <tr>
 | 
					  <tr>
 | 
				
			||||||
    <td><code>s3</code></td>
 | 
					    <td><code>s3</code></td>
 | 
				
			||||||
    <td>Uses Amazon's Simple Storage Service (S3).
 | 
					    <td>Uses Amazon's Simple Storage Service (S3) and compatible Storage Services.
 | 
				
			||||||
    See the <a href="storage-drivers/s3.md">driver's reference documentation</a>.
 | 
					    See the <a href="storage-drivers/s3.md">driver's reference documentation</a>.
 | 
				
			||||||
    </td>
 | 
					    </td>
 | 
				
			||||||
  </tr>
 | 
					  </tr>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -9,7 +9,7 @@ keywords = ["registry, service, driver, images, storage,  S3"]
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# S3 storage driver
 | 
					# S3 storage driver
 | 
				
			||||||
 | 
					
 | 
				
			||||||
An implementation of the `storagedriver.StorageDriver` interface which uses Amazon S3 for object storage.
 | 
					An implementation of the `storagedriver.StorageDriver` interface which uses Amazon S3 or S3 compatible services for object storage.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
## Parameters
 | 
					## Parameters
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -52,6 +52,17 @@ An implementation of the `storagedriver.StorageDriver` interface which uses Amaz
 | 
				
			||||||
      The AWS region in which your bucket exists. For the moment, the Go AWS
 | 
					      The AWS region in which your bucket exists. For the moment, the Go AWS
 | 
				
			||||||
      library in use does not use the newer DNS based bucket routing.
 | 
					      library in use does not use the newer DNS based bucket routing.
 | 
				
			||||||
    </td>
 | 
					    </td>
 | 
				
			||||||
 | 
					  </tr>
 | 
				
			||||||
 | 
					  <tr>
 | 
				
			||||||
 | 
					    <td>
 | 
				
			||||||
 | 
					      <code>regionendpoint</code>
 | 
				
			||||||
 | 
					    </td>
 | 
				
			||||||
 | 
					    <td>
 | 
				
			||||||
 | 
					      no
 | 
				
			||||||
 | 
					    </td>
 | 
				
			||||||
 | 
					    <td>
 | 
				
			||||||
 | 
					      Endpoint for S3 compatible storage services (Minio, etc)
 | 
				
			||||||
 | 
					    </td>
 | 
				
			||||||
  </tr>
 | 
					  </tr>
 | 
				
			||||||
    <tr>
 | 
					    <tr>
 | 
				
			||||||
    <td>
 | 
					    <td>
 | 
				
			||||||
| 
						 | 
					@ -146,6 +157,8 @@ An implementation of the `storagedriver.StorageDriver` interface which uses Amaz
 | 
				
			||||||
 | 
					
 | 
				
			||||||
`region`: The name of the aws region in which you would like to store objects (for example `us-east-1`). For a list of regions, you can look at http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html
 | 
					`region`: The name of the aws region in which you would like to store objects (for example `us-east-1`). For a list of regions, you can look at http://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					`regionendpoint`: (optional) Endpoint URL for S3 compatible APIs. This should not be provided when using Amazon S3.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
`bucket`: The name of your S3 bucket where you wish to store objects. The bucket must exist prior to the driver initialization.
 | 
					`bucket`: The name of your S3 bucket where you wish to store objects. The bucket must exist prior to the driver initialization.
 | 
				
			||||||
 | 
					
 | 
				
			||||||
`encrypt`: (optional) Whether you would like your data encrypted on the server side (defaults to false if not specified).
 | 
					`encrypt`: (optional) Whether you would like your data encrypted on the server side (defaults to false if not specified).
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -56,16 +56,17 @@ var validRegions = map[string]struct{}{}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
//DriverParameters A struct that encapsulates all of the driver parameters after all values have been set
 | 
					//DriverParameters A struct that encapsulates all of the driver parameters after all values have been set
 | 
				
			||||||
type DriverParameters struct {
 | 
					type DriverParameters struct {
 | 
				
			||||||
	AccessKey     string
 | 
						AccessKey      string
 | 
				
			||||||
	SecretKey     string
 | 
						SecretKey      string
 | 
				
			||||||
	Bucket        string
 | 
						Bucket         string
 | 
				
			||||||
	Region        string
 | 
						Region         string
 | 
				
			||||||
	Encrypt       bool
 | 
						RegionEndpoint string
 | 
				
			||||||
	Secure        bool
 | 
						Encrypt        bool
 | 
				
			||||||
	ChunkSize     int64
 | 
						Secure         bool
 | 
				
			||||||
	RootDirectory string
 | 
						ChunkSize      int64
 | 
				
			||||||
	StorageClass  string
 | 
						RootDirectory  string
 | 
				
			||||||
	UserAgent     string
 | 
						StorageClass   string
 | 
				
			||||||
 | 
						UserAgent      string
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
func init() {
 | 
					func init() {
 | 
				
			||||||
| 
						 | 
					@ -153,6 +154,11 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
 | 
				
			||||||
		return nil, fmt.Errorf("No bucket parameter provided")
 | 
							return nil, fmt.Errorf("No bucket parameter provided")
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
						regionEndpoint := parameters["regionendpoint"]
 | 
				
			||||||
 | 
						if regionEndpoint == nil {
 | 
				
			||||||
 | 
							regionEndpoint = ""
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	encryptBool := false
 | 
						encryptBool := false
 | 
				
			||||||
	encrypt := parameters["encrypt"]
 | 
						encrypt := parameters["encrypt"]
 | 
				
			||||||
	switch encrypt := encrypt.(type) {
 | 
						switch encrypt := encrypt.(type) {
 | 
				
			||||||
| 
						 | 
					@ -240,6 +246,7 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
 | 
				
			||||||
		fmt.Sprint(secretKey),
 | 
							fmt.Sprint(secretKey),
 | 
				
			||||||
		fmt.Sprint(bucket),
 | 
							fmt.Sprint(bucket),
 | 
				
			||||||
		region,
 | 
							region,
 | 
				
			||||||
 | 
							fmt.Sprint(regionEndpoint),
 | 
				
			||||||
		encryptBool,
 | 
							encryptBool,
 | 
				
			||||||
		secureBool,
 | 
							secureBool,
 | 
				
			||||||
		chunkSize,
 | 
							chunkSize,
 | 
				
			||||||
| 
						 | 
					@ -255,22 +262,37 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
 | 
				
			||||||
// bucketName
 | 
					// bucketName
 | 
				
			||||||
func New(params DriverParameters) (*Driver, error) {
 | 
					func New(params DriverParameters) (*Driver, error) {
 | 
				
			||||||
	awsConfig := aws.NewConfig()
 | 
						awsConfig := aws.NewConfig()
 | 
				
			||||||
	creds := credentials.NewChainCredentials([]credentials.Provider{
 | 
						var creds *credentials.Credentials
 | 
				
			||||||
		&credentials.StaticProvider{
 | 
						if params.RegionEndpoint == "" {
 | 
				
			||||||
			Value: credentials.Value{
 | 
							creds = credentials.NewChainCredentials([]credentials.Provider{
 | 
				
			||||||
				AccessKeyID:     params.AccessKey,
 | 
								&credentials.StaticProvider{
 | 
				
			||||||
				SecretAccessKey: params.SecretKey,
 | 
									Value: credentials.Value{
 | 
				
			||||||
 | 
										AccessKeyID:     params.AccessKey,
 | 
				
			||||||
 | 
										SecretAccessKey: params.SecretKey,
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
			},
 | 
								},
 | 
				
			||||||
		},
 | 
								&credentials.EnvProvider{},
 | 
				
			||||||
		&credentials.EnvProvider{},
 | 
								&credentials.SharedCredentialsProvider{},
 | 
				
			||||||
		&credentials.SharedCredentialsProvider{},
 | 
								&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(session.New())},
 | 
				
			||||||
		&ec2rolecreds.EC2RoleProvider{Client: ec2metadata.New(session.New())},
 | 
							})
 | 
				
			||||||
	})
 | 
					
 | 
				
			||||||
 | 
						} else {
 | 
				
			||||||
 | 
							creds = credentials.NewChainCredentials([]credentials.Provider{
 | 
				
			||||||
 | 
								&credentials.StaticProvider{
 | 
				
			||||||
 | 
									Value: credentials.Value{
 | 
				
			||||||
 | 
										AccessKeyID:     params.AccessKey,
 | 
				
			||||||
 | 
										SecretAccessKey: params.SecretKey,
 | 
				
			||||||
 | 
									},
 | 
				
			||||||
 | 
								},
 | 
				
			||||||
 | 
								&credentials.EnvProvider{},
 | 
				
			||||||
 | 
							})
 | 
				
			||||||
 | 
							awsConfig.WithS3ForcePathStyle(true)
 | 
				
			||||||
 | 
							awsConfig.WithEndpoint(params.RegionEndpoint)
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	awsConfig.WithCredentials(creds)
 | 
						awsConfig.WithCredentials(creds)
 | 
				
			||||||
	awsConfig.WithRegion(params.Region)
 | 
						awsConfig.WithRegion(params.Region)
 | 
				
			||||||
	awsConfig.WithDisableSSL(!params.Secure)
 | 
						awsConfig.WithDisableSSL(!params.Secure)
 | 
				
			||||||
	// awsConfig.WithMaxRetries(10)
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if params.UserAgent != "" {
 | 
						if params.UserAgent != "" {
 | 
				
			||||||
		awsConfig.WithHTTPClient(&http.Client{
 | 
							awsConfig.WithHTTPClient(&http.Client{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -30,6 +30,7 @@ func init() {
 | 
				
			||||||
	secure := os.Getenv("S3_SECURE")
 | 
						secure := os.Getenv("S3_SECURE")
 | 
				
			||||||
	region := os.Getenv("AWS_REGION")
 | 
						region := os.Getenv("AWS_REGION")
 | 
				
			||||||
	root, err := ioutil.TempDir("", "driver-")
 | 
						root, err := ioutil.TempDir("", "driver-")
 | 
				
			||||||
 | 
						regionEndpoint := os.Getenv("REGION_ENDPOINT")
 | 
				
			||||||
	if err != nil {
 | 
						if err != nil {
 | 
				
			||||||
		panic(err)
 | 
							panic(err)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					@ -57,6 +58,7 @@ func init() {
 | 
				
			||||||
			secretKey,
 | 
								secretKey,
 | 
				
			||||||
			bucket,
 | 
								bucket,
 | 
				
			||||||
			region,
 | 
								region,
 | 
				
			||||||
 | 
								regionEndpoint,
 | 
				
			||||||
			encryptBool,
 | 
								encryptBool,
 | 
				
			||||||
			secureBool,
 | 
								secureBool,
 | 
				
			||||||
			minChunkSize,
 | 
								minChunkSize,
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue