From 3183cf0e2e72d57576b0aa7fa57ab117e6295d5d Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Sun, 7 Mar 2021 08:47:24 -0700 Subject: [PATCH] Add support for Linode Object Storage replica URLs This commit adds the ability to specify Linode Object Storage as replica URLs in the command line and configuration file: s3://MYBKT.us-east-1.linodeobjects.com/MYPATH --- s3/s3.go | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/s3/s3.go b/s3/s3.go index e515bd8..3d3a95c 100644 --- a/s3/s3.go +++ b/s3/s3.go @@ -1139,13 +1139,14 @@ func ParseHost(s string) (bucket, region, endpoint string, forcePathStyle bool) 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]) + bucket, region = a[1], a[2] + endpoint = fmt.Sprintf("%s.digitaloceanspaces.com", region) + } 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 { - bucket = a[1] - region = a[2] - endpoint = fmt.Sprintf("s3.%s.backblazeb2.com", a[2]) + bucket, region = a[1], a[2] + endpoint = fmt.Sprintf("s3.%s.backblazeb2.com", region) } else { bucket = host forcePathStyle = false @@ -1167,6 +1168,7 @@ func ParseHost(s string) (bucket, region, endpoint string, forcePathStyle bool) var ( localhostRegex = regexp.MustCompile(`^(?:(.+)\.)?localhost$`) digitalOceanRegex = regexp.MustCompile(`^(?:(.+)\.)?([^.]+)\.digitaloceanspaces.com$`) + linodeRegex = regexp.MustCompile(`^(?:(.+)\.)?([^.]+)\.linodeobjects.com$`) backblazeRegex = regexp.MustCompile(`^(?:(.+)\.)?s3.([^.]+)\.backblazeb2.com$`) gcsRegex = regexp.MustCompile(`^(?:(.+)\.)?storage.googleapis.com$`) )