From 98673c67851c1f009e21ec6c21198bda76bf23e6 Mon Sep 17 00:00:00 2001 From: Hiroaki Nakamura Date: Sat, 14 May 2022 00:28:57 +0900 Subject: [PATCH] Add environment variables for scheme and forcePathStyle --- s3/replica_client.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/s3/replica_client.go b/s3/replica_client.go index d551288..6e6696b 100644 --- a/s3/replica_client.go +++ b/s3/replica_client.go @@ -10,6 +10,7 @@ import ( "os" "path" "regexp" + "strconv" "strings" "sync" "time" @@ -703,12 +704,26 @@ func ParseHost(s string) (bucket, region, endpoint string, forcePathStyle bool) endpoint = net.JoinHostPort(endpoint, port) } + if s := os.Getenv("LITESTREAM_SCHEME"); s != "" { + if s != "https" && s != "http" { + panic(fmt.Sprintf("Unsupported LITESTREAM_SCHEME value: %q", s)) + } else { + scheme = s + } + } if e := os.Getenv("LITESTREAM_ENDPOINT"); e != "" { endpoint = e } if r := os.Getenv("LITESTREAM_REGION"); r != "" { region = r } + if s := os.Getenv("LITESTREAM_FORCE_PATH_STYLE"); s != "" { + if b, err := strconv.ParseBool(s); err != nil { + panic(fmt.Sprintf("Invalid LITESTREAM_FORCE_PATH_STYLE value: %q", s)) + } else { + forcePathStyle = b + } + } // Prepend scheme to endpoint. if endpoint != "" {