Skip to content

Commit 3bbc551

Browse files
committed
Merge branch 'ryan/db-env-vars' into 'main'
Add extra DB env var overrides See merge request flarenetwork/FSP/flare-system-c-chain-indexer!73
2 parents 350ac5a + 005d8bc commit 3bbc551

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

config/config.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import (
99
"math/big"
1010
"net/url"
1111
"os"
12+
"strconv"
1213
"time"
1314

1415
"github.com/BurntSushi/toml"
@@ -210,6 +211,17 @@ func (cc ChainConfig) FullNodeURL() (*url.URL, error) {
210211
}
211212

212213
var envOverrides = map[string]func(*Config, string){
214+
"DB_HOST": func(c *Config, v string) { c.DB.Host = v },
215+
"DB_PORT": func(c *Config, v string) {
216+
port, err := strconv.Atoi(v)
217+
if err == nil {
218+
c.DB.Port = port
219+
} else {
220+
// The logger is not yet initialized here, so we use fmt.Printf
221+
fmt.Printf("ERROR: Invalid DB_PORT value: %s\n", v)
222+
}
223+
},
224+
"DB_DATABASE": func(c *Config, v string) { c.DB.Database = v },
213225
"DB_USERNAME": func(c *Config, v string) { c.DB.Username = v },
214226
"DB_PASSWORD": func(c *Config, v string) { c.DB.Password = v },
215227
"NODE_URL": func(c *Config, v string) { c.Chain.NodeURL = v },

0 commit comments

Comments
 (0)