Skip to content

Commit

Permalink
Merge pull request #151 from lionello/credentialsEndpoint-config
Browse files Browse the repository at this point in the history
Add credentialsEndpoint config
  • Loading branch information
Stebalien authored Feb 19, 2021
2 parents e21b6fe + 33172a0 commit 1f4bf9d
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 24 deletions.
24 changes: 16 additions & 8 deletions plugin/s3ds.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,17 +90,25 @@ func (s3p S3Plugin) DatastoreConfigParser() fsrepo.ConfigFromMap {
return nil, fmt.Errorf("s3ds: workers is not an integer: %f", workersf)
}
}
var credentialsEndpoint string
if v, ok := m["credentialsEndpoint"]; ok {
credentialsEndpoint, ok = v.(string)
if !ok {
return nil, fmt.Errorf("s3ds: credentialsEndpoint not a string")
}
}

return &S3Config{
cfg: s3ds.Config{
Region: region,
Bucket: bucket,
AccessKey: accessKey,
SecretKey: secretKey,
SessionToken: sessionToken,
RootDirectory: rootDirectory,
Workers: workers,
RegionEndpoint: endpoint,
Region: region,
Bucket: bucket,
AccessKey: accessKey,
SecretKey: secretKey,
SessionToken: sessionToken,
RootDirectory: rootDirectory,
Workers: workers,
RegionEndpoint: endpoint,
CredentialsEndpoint: credentialsEndpoint,
},
}, nil
}
Expand Down
34 changes: 18 additions & 16 deletions plugin/s3ds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,24 +38,26 @@ func TestS3PluginDatastoreConfigParser(t *testing.T) {
{
// Optional fields included
Input: map[string]interface{}{
"region": "someregion",
"bucket": "somebucket",
"accessKey": "someaccesskey",
"secretKey": "somesecretkey",
"sessionToken": "somesessiontoken",
"rootDirectory": "/some/path",
"regionEndpoint": "someendpoint",
"workers": 42.0,
"region": "someregion",
"bucket": "somebucket",
"accessKey": "someaccesskey",
"secretKey": "somesecretkey",
"sessionToken": "somesessiontoken",
"rootDirectory": "/some/path",
"regionEndpoint": "someendpoint",
"workers": 42.0,
"credentialsEndpoint": "somecredendpoint",
},
Want: &S3Config{cfg: s3ds.Config{
Region: "someregion",
Bucket: "somebucket",
AccessKey: "someaccesskey",
SecretKey: "somesecretkey",
SessionToken: "somesessiontoken",
RootDirectory: "/some/path",
RegionEndpoint: "someendpoint",
Workers: 42,
Region: "someregion",
Bucket: "somebucket",
AccessKey: "someaccesskey",
SecretKey: "somesecretkey",
SessionToken: "somesessiontoken",
RootDirectory: "/some/path",
RegionEndpoint: "someendpoint",
Workers: 42,
CredentialsEndpoint: "somecredendpoint",
}},
},
}
Expand Down

0 comments on commit 1f4bf9d

Please sign in to comment.