From e4c1a82eb2fde5e60fd462691c51dbc3f6ef1d78 Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Sun, 7 Mar 2021 08:25:26 -0700 Subject: [PATCH] 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 --- s3/s3.go | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/s3/s3.go b/s3/s3.go index b4424dd..e515bd8 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -1138,6 +1138,10 @@ func ParseHost(s string) (bucket, region, endpoint string, forcePathStyle bool) } else if a := gcsRegex.FindStringSubmatch(host); a != nil { bucket, region = a[1], "us-east-1" 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 { bucket = a[1] region = a[2] @@ -1161,9 +1165,10 @@ func ParseHost(s string) (bucket, region, endpoint string, forcePathStyle bool) } var ( - localhostRegex = regexp.MustCompile(`^(?:(.+)\.)?localhost$`) - backblazeRegex = regexp.MustCompile(`^(?:(.+)\.)?s3.([^.]+)\.backblazeb2.com$`) - gcsRegex = regexp.MustCompile(`^(?:(.+)\.)?storage.googleapis.com$`) + localhostRegex = regexp.MustCompile(`^(?:(.+)\.)?localhost$`) + digitalOceanRegex = regexp.MustCompile(`^(?:(.+)\.)?([^.]+)\.digitaloceanspaces.com$`) + backblazeRegex = regexp.MustCompile(`^(?:(.+)\.)?s3.([^.]+)\.backblazeb2.com$`) + gcsRegex = regexp.MustCompile(`^(?:(.+)\.)?storage.googleapis.com$`) ) // S3 metrics.