mirror of https://github.com/kubernetes/kops.git
Merge pull request #8787 from johanneswuerbach/s3-virtual-host
Support S3 Virtual Hosted Style
This commit is contained in:
commit
c91c7ccc76
|
|
@ -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"]
|
||||
|
|
|
|||
|
|
@ -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: "",
|
||||
|
|
|
|||
Loading…
Reference in New Issue