Skip to content

Commit

Permalink
Merge pull request #9 from ndv6/feature/implement-migration
Browse files Browse the repository at this point in the history
Feature/implement migration
  • Loading branch information
Lazycious authored Dec 27, 2022
2 parents 18c1715 + 6a27e27 commit 88e5a81
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ const (
)

var (
typ = DefaultType
fname = DefaultFilename
prefix string
typ = DefaultType
fname = DefaultFilename
prefix, token string

c *viper.Viper
dirs = []string{
Expand Down Expand Up @@ -69,6 +69,12 @@ func Configure() {
if v := os.Getenv(EnvPrefixKey); len(v) > 0 {
prefix = v
}
if v := os.Getenv(EnvHttpToken); len(v) > 0 {
token = v
}
if v := os.Getenv(EnvHttpTokenFile); len(v) > 0 {
token = v
}

// setup and configure viper instance
c = viper.New()
Expand All @@ -77,11 +83,12 @@ func Configure() {
if len(prefix) > 0 {
c.SetEnvPrefix(prefix)
}

c.AutomaticEnv()

// next we load from consul; only if consul host defined
if ch := os.Getenv(EnvConsulHostKey); ch != "" {
if err := c.AddRemoteProvider("consul", ch, fname); err != nil {
if err := c.AddSecureRemoteProvider("consul", ch, fname, token); err != nil {
errConsul = errors.Cause(err)
} else {
connect := func() error { return c.ReadRemoteConfig() }
Expand Down

0 comments on commit 88e5a81

Please sign in to comment.