Merge pull request #8787 from johanneswuerbach/s3-virtual-host

Support S3 Virtual Hosted Style
This commit is contained in:
Kubernetes Prow Robot 2020-05-02 23:52:26 -07:00 committed by GitHub
commit c91c7ccc76
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 2 deletions

View File

@ -42,7 +42,7 @@ var (
// https://docs.aws.amazon.com/general/latest/gr/rande.html#s3_region
// TODO: perhaps make region regex more specific, i.e. (us|eu|ap|cn|ca|sa), to prevent matching bucket names that match region format?
// but that will mean updating this list when AWS introduces new regions
s3UrlRegexp = regexp.MustCompile(`s3([-.](?P<region>\w{2}-\w+-\d{1})|[-.](?P<bucket>[\w.\-\_]+)|)?.amazonaws.com(.cn)?(?P<path>.*)?`)
s3UrlRegexp = regexp.MustCompile(`(s3([-.](?P<region>\w{2}-\w+-\d{1})|[-.](?P<bucket>[\w.\-\_]+)|)?|(?P<bucket>[\w.\-\_]+).s3.(?P<region>\w{2}-\w+-\d{1})).amazonaws.com(.cn)?(?P<path>.*)?`)
)
type S3BucketDetails struct {
@ -385,7 +385,9 @@ func VFSPath(url string) (string, error) {
captured := map[string]string{}
for i, value := range result {
captured[groupNames[i]] = value
if value != "" {
captured[groupNames[i]] = value
}
}
bucket := captured["bucket"]
path := captured["path"]

View File

@ -79,6 +79,11 @@ func Test_VFSPath(t *testing.T) {
ExpectedResult: "s3://bucket",
ExpectError: false,
},
{
Input: "https://bucket-name.s3.us-east-1.amazonaws.com/path",
ExpectedResult: "s3://bucket-name/path",
ExpectError: false,
},
{
Input: "example.com/bucket",
ExpectedResult: "",