From 929a66314cf5555cc38e67ae06cbf349c674f76b Mon Sep 17 00:00:00 2001 From: Ben Johnson Date: Thu, 11 Mar 2021 15:26:41 -0700 Subject: [PATCH] Default to force path style if endpoint set This commit changes the replica configuration behavior to default the `force-path-style` field to `true` when an `endpoint` is set. This works because the only service that does not use the path style is AWS S3 which does not use an endpoint. --- cmd/litestream/main.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/cmd/litestream/main.go b/cmd/litestream/main.go index 2a146d3..ac1e6e9 100644 --- a/cmd/litestream/main.go +++ b/cmd/litestream/main.go @@ -271,7 +271,7 @@ type ReplicaConfig struct { Region string `yaml:"region"` Bucket string `yaml:"bucket"` Endpoint string `yaml:"endpoint"` - ForcePathStyle bool `yaml:"force-path-style"` + ForcePathStyle *bool `yaml:"force-path-style"` } // NewReplicaFromConfig instantiates a replica for a DB based on a config. @@ -343,7 +343,14 @@ func newS3ReplicaFromConfig(c *ReplicaConfig, db *litestream.DB) (_ *s3.Replica, } bucket, path := c.Bucket, c.Path - region, endpoint, forcePathStyle := c.Region, c.Endpoint, c.ForcePathStyle + region, endpoint := c.Region, c.Endpoint + + // Use path style if an endpoint is explicitly set. This works because the + // only service to not use path style is AWS which does not use an endpoint. + forcePathStyle := (endpoint != "") + if v := c.ForcePathStyle; v != nil { + forcePathStyle = *v + } // Apply settings from URL, if specified. if c.URL != "" {