Skip to content
Snippets Groups Projects
Unverified Commit 3f86f9a8 authored by Jonas Theis's avatar Jonas Theis Committed by GitHub
Browse files

Enable configuration via ENV variables (#481)

parent 53c315e5
Branches
Tags
No related merge requests found
...@@ -3,6 +3,7 @@ package config ...@@ -3,6 +3,7 @@ package config
import ( import (
"fmt" "fmt"
"os" "os"
"strings"
"github.com/iotaledger/hive.go/events" "github.com/iotaledger/hive.go/events"
"github.com/iotaledger/hive.go/node" "github.com/iotaledger/hive.go/node"
...@@ -56,6 +57,12 @@ func init() { ...@@ -56,6 +57,12 @@ func init() {
// It automatically reads in a single config file starting with "config" (can be changed via the --config CLI flag) // It automatically reads in a single config file starting with "config" (can be changed via the --config CLI flag)
// and ending with: .json, .toml, .yaml or .yml (in this sequence). // and ending with: .json, .toml, .yaml or .yml (in this sequence).
func fetch(printConfig bool, ignoreSettingsAtPrint ...[]string) error { func fetch(printConfig bool, ignoreSettingsAtPrint ...[]string) error {
// replace dots with underscores in env
dotReplacer := strings.NewReplacer(".", "_")
Node.SetEnvKeyReplacer(dotReplacer)
// read in ENV variables
Node.AutomaticEnv()
flag.Parse() flag.Parse()
err := parameter.LoadConfigFile(Node, *configDirPath, *configName, true, *skipConfigAvailable) err := parameter.LoadConfigFile(Node, *configDirPath, *configName, true, *skipConfigAvailable)
if err != nil { if err != nil {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment