Skip to content
This repository was archived by the owner on Jan 14, 2020. It is now read-only.

Commit c8d5972

Browse files
Merge pull request #24 from gocardless/lawrence-support-environment-variable-config
Support loading config from environment variables
2 parents 2be3bb2 + b22c9d7 commit c8d5972

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

command/commands.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package command
33
import (
44
"os"
55
"os/signal"
6+
"strings"
67
"syscall"
78
"time"
89

@@ -30,6 +31,12 @@ var (
3031
)
3132

3233
func init() {
34+
// Configure viper so that command-line flags are used as a priority, followed by
35+
// environment variables, followed by the supplied defaults
36+
viper.AutomaticEnv()
37+
viper.SetEnvPrefix("pgsql")
38+
viper.SetEnvKeyReplacer(strings.NewReplacer("-", "_"))
39+
3340
flags := PgsqlCommand.PersistentFlags()
3441

3542
// We always need an etcd connection, so these flags are for all commands

0 commit comments

Comments
 (0)