Add support for DigitalOcean Spaces replica URLs

This commit adds the ability to specify DigitalOcean Spaces as
replica URLs in the command line and configuration file:

	s3://mybkt.nyc3.digitaloceanspaces.com/mypath
This commit is contained in:
Ben Johnson
2021-03-07 08:25:26 -07:00
parent aa54e4698d
commit e4c1a82eb2

View File

@@ -1138,6 +1138,10 @@ func ParseHost(s string) (bucket, region, endpoint string, forcePathStyle bool)
} else if a := gcsRegex.FindStringSubmatch(host); a != nil { } else if a := gcsRegex.FindStringSubmatch(host); a != nil {
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 {
bucket = a[1]
region = a[2]
endpoint = fmt.Sprintf("%s.digitaloceanspaces.com", a[2])
} else if a := backblazeRegex.FindStringSubmatch(host); a != nil { } else if a := backblazeRegex.FindStringSubmatch(host); a != nil {
bucket = a[1] bucket = a[1]
region = a[2] region = a[2]
@@ -1162,6 +1166,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$`)
backblazeRegex = regexp.MustCompile(`^(?:(.+)\.)?s3.([^.]+)\.backblazeb2.com$`) backblazeRegex = regexp.MustCompile(`^(?:(.+)\.)?s3.([^.]+)\.backblazeb2.com$`)
gcsRegex = regexp.MustCompile(`^(?:(.+)\.)?storage.googleapis.com$`) gcsRegex = regexp.MustCompile(`^(?:(.+)\.)?storage.googleapis.com$`)
) )