Allow use of LITESTREAM prefixed environment variables
This commit adds optional `LITESTREAM_ACCESS_KEY_ID` and `LITESTREAM_SECRET_ACCESS_KEY` environment variables that can be used instead of their `AWS` counterparts. The AWS-prefixed variables have caused some confusion with users who were not using AWS S3.
This commit is contained in:
@@ -61,6 +61,9 @@ func (m *Main) Run(ctx context.Context, args []string) (err error) {
|
|||||||
return runWindowsService(ctx)
|
return runWindowsService(ctx)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Copy "LITESTEAM" environment credentials.
|
||||||
|
applyLitestreamEnv()
|
||||||
|
|
||||||
// Extract command name.
|
// Extract command name.
|
||||||
var cmd string
|
var cmd string
|
||||||
if len(args) > 0 {
|
if len(args) > 0 {
|
||||||
@@ -427,6 +430,22 @@ func newS3ReplicaFromConfig(c *ReplicaConfig, db *litestream.DB) (_ *s3.Replica,
|
|||||||
return r, nil
|
return r, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// applyLitestreamEnv copies "LITESTREAM" prefixed environment variables to
|
||||||
|
// their AWS counterparts as the "AWS" prefix can be confusing when using a
|
||||||
|
// non-AWS S3-compatible service.
|
||||||
|
func applyLitestreamEnv() {
|
||||||
|
if v, ok := os.LookupEnv("LITESTREAM_ACCESS_KEY_ID"); ok {
|
||||||
|
if _, ok := os.LookupEnv("AWS_ACCESS_KEY_ID"); !ok {
|
||||||
|
os.Setenv("AWS_ACCESS_KEY_ID", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if v, ok := os.LookupEnv("LITESTREAM_SECRET_ACCESS_KEY"); ok {
|
||||||
|
if _, ok := os.LookupEnv("AWS_SECRET_ACCESS_KEY"); !ok {
|
||||||
|
os.Setenv("AWS_SECRET_ACCESS_KEY", v)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ParseReplicaURL parses a replica URL.
|
// ParseReplicaURL parses a replica URL.
|
||||||
func ParseReplicaURL(s string) (scheme, host, urlpath string, err error) {
|
func ParseReplicaURL(s string) (scheme, host, urlpath string, err error) {
|
||||||
u, err := url.Parse(s)
|
u, err := url.Parse(s)
|
||||||
|
|||||||
Reference in New Issue
Block a user