From 3f86f9a8c990f8cf60e3bf24e9b864994ca1e73d Mon Sep 17 00:00:00 2001
From: Jonas Theis <mail@jonastheis.de>
Date: Tue, 16 Jun 2020 08:55:03 +0200
Subject: [PATCH] Enable configuration via ENV variables (#481)

---
 plugins/config/plugin.go | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/plugins/config/plugin.go b/plugins/config/plugin.go
index ab43e605..da882233 100644
--- a/plugins/config/plugin.go
+++ b/plugins/config/plugin.go
@@ -3,6 +3,7 @@ package config
 import (
 	"fmt"
 	"os"
+	"strings"
 
 	"github.com/iotaledger/hive.go/events"
 	"github.com/iotaledger/hive.go/node"
@@ -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)
 // and ending with: .json, .toml, .yaml or .yml (in this sequence).
 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()
 	err := parameter.LoadConfigFile(Node, *configDirPath, *configName, true, *skipConfigAvailable)
 	if err != nil {
-- 
GitLab