Skip to content

Commit 929a663

Browse files
committed
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.
1 parent 2e7a6ae commit 929a663

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

cmd/litestream/main.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ type ReplicaConfig struct {
271271
Region string `yaml:"region"`
272272
Bucket string `yaml:"bucket"`
273273
Endpoint string `yaml:"endpoint"`
274-
ForcePathStyle bool `yaml:"force-path-style"`
274+
ForcePathStyle *bool `yaml:"force-path-style"`
275275
}
276276

277277
// NewReplicaFromConfig instantiates a replica for a DB based on a config.
@@ -343,7 +343,14 @@ func newS3ReplicaFromConfig(c *ReplicaConfig, db *litestream.DB) (_ *s3.Replica,
343343
}
344344

345345
bucket, path := c.Bucket, c.Path
346-
region, endpoint, forcePathStyle := c.Region, c.Endpoint, c.ForcePathStyle
346+
region, endpoint := c.Region, c.Endpoint
347+
348+
// Use path style if an endpoint is explicitly set. This works because the
349+
// only service to not use path style is AWS which does not use an endpoint.
350+
forcePathStyle := (endpoint != "")
351+
if v := c.ForcePathStyle; v != nil {
352+
forcePathStyle = *v
353+
}
347354

348355
// Apply settings from URL, if specified.
349356
if c.URL != "" {

0 commit comments

Comments
 (0)