Add environment variables for scheme and forcePathStyle

This commit is contained in:
Hiroaki Nakamura
2022-05-14 00:28:57 +09:00
committed by Ben Johnson
parent 46597ab22f
commit 98673c6785

View File

@@ -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 != "" {