mirror of
https://github.com/distribution/distribution.git
synced 2025-08-20 15:55:27 +00:00
s3: accept S3 parameter
This commit is contained in:
parent
03ff763453
commit
aabf07ec65
@ -84,6 +84,10 @@ var validObjectACLs = map[string]struct{}{}
|
||||
|
||||
//DriverParameters A struct that encapsulates all of the driver parameters after all values have been set
|
||||
type DriverParameters struct {
|
||||
// S3 is an optional parameter. If specified, it will use the existing session
|
||||
// to construct the Driver.
|
||||
S3 *s3.S3
|
||||
|
||||
AccessKey string
|
||||
SecretKey string
|
||||
Bucket string
|
||||
@ -342,6 +346,7 @@ func FromParameters(parameters map[string]interface{}) (*Driver, error) {
|
||||
sessionToken := ""
|
||||
|
||||
params := DriverParameters{
|
||||
nil,
|
||||
fmt.Sprint(accessKey),
|
||||
fmt.Sprint(secretKey),
|
||||
fmt.Sprint(bucket),
|
||||
@ -398,6 +403,8 @@ func getParameterAsInt64(parameters map[string]interface{}, name string, default
|
||||
// New constructs a new Driver with the given AWS credentials, region, encryption flag, and
|
||||
// bucketName
|
||||
func New(params DriverParameters) (*Driver, error) {
|
||||
s3obj := params.S3
|
||||
if s3obj == nil {
|
||||
if !params.V4Auth &&
|
||||
(params.RegionEndpoint == "" ||
|
||||
strings.Contains(params.RegionEndpoint, "s3.amazonaws.com")) {
|
||||
@ -453,12 +460,13 @@ func New(params DriverParameters) (*Driver, error) {
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to create new session with aws config: %v", err)
|
||||
}
|
||||
s3obj := s3.New(sess)
|
||||
s3obj = s3.New(sess)
|
||||
|
||||
// enable S3 compatible signature v2 signing instead
|
||||
if !params.V4Auth {
|
||||
setv2Handlers(s3obj)
|
||||
}
|
||||
}
|
||||
|
||||
// TODO Currently multipart uploads have no timestamps, so this would be unwise
|
||||
// if you initiated a new s3driver while another one is running on the same bucket.
|
||||
|
@ -77,6 +77,7 @@ func init() {
|
||||
}
|
||||
|
||||
parameters := DriverParameters{
|
||||
nil,
|
||||
accessKey,
|
||||
secretKey,
|
||||
bucket,
|
||||
|
Loading…
Reference in New Issue
Block a user