Merge pull request #111 from benbjohnson/linode

Add support for Linode Object Storage replica URLs
This commit is contained in:
Ben Johnson
2021-03-07 08:55:29 -07:00
committed by GitHub

View File

@@ -1139,13 +1139,14 @@ func ParseHost(s string) (bucket, region, endpoint string, forcePathStyle bool)
bucket, region = a[1], "us-east-1" bucket, region = a[1], "us-east-1"
endpoint = "storage.googleapis.com" endpoint = "storage.googleapis.com"
} else if a := digitalOceanRegex.FindStringSubmatch(host); a != nil { } else if a := digitalOceanRegex.FindStringSubmatch(host); a != nil {
bucket = a[1] bucket, region = a[1], a[2]
region = a[2] endpoint = fmt.Sprintf("%s.digitaloceanspaces.com", region)
endpoint = fmt.Sprintf("%s.digitaloceanspaces.com", a[2]) } else if a := linodeRegex.FindStringSubmatch(host); a != nil {
bucket, region = a[1], a[2]
endpoint = fmt.Sprintf("%s.linodeobjects.com", region)
} else if a := backblazeRegex.FindStringSubmatch(host); a != nil { } else if a := backblazeRegex.FindStringSubmatch(host); a != nil {
bucket = a[1] bucket, region = a[1], a[2]
region = a[2] endpoint = fmt.Sprintf("s3.%s.backblazeb2.com", region)
endpoint = fmt.Sprintf("s3.%s.backblazeb2.com", a[2])
} else { } else {
bucket = host bucket = host
forcePathStyle = false forcePathStyle = false
@@ -1167,6 +1168,7 @@ func ParseHost(s string) (bucket, region, endpoint string, forcePathStyle bool)
var ( var (
localhostRegex = regexp.MustCompile(`^(?:(.+)\.)?localhost$`) localhostRegex = regexp.MustCompile(`^(?:(.+)\.)?localhost$`)
digitalOceanRegex = regexp.MustCompile(`^(?:(.+)\.)?([^.]+)\.digitaloceanspaces.com$`) digitalOceanRegex = regexp.MustCompile(`^(?:(.+)\.)?([^.]+)\.digitaloceanspaces.com$`)
linodeRegex = regexp.MustCompile(`^(?:(.+)\.)?([^.]+)\.linodeobjects.com$`)
backblazeRegex = regexp.MustCompile(`^(?:(.+)\.)?s3.([^.]+)\.backblazeb2.com$`) backblazeRegex = regexp.MustCompile(`^(?:(.+)\.)?s3.([^.]+)\.backblazeb2.com$`)
gcsRegex = regexp.MustCompile(`^(?:(.+)\.)?storage.googleapis.com$`) gcsRegex = regexp.MustCompile(`^(?:(.+)\.)?storage.googleapis.com$`)
) )