From e58fbcba5c80edff4441e6909244c8578f3b883d Mon Sep 17 00:00:00 2001 From: Finn Date: Sun, 20 Oct 2024 21:51:17 -0700 Subject: [PATCH] allow env overriding config file path --- config/config.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/config/config.go b/config/config.go index ae24f83..c8c9282 100644 --- a/config/config.go +++ b/config/config.go @@ -3,6 +3,7 @@ package config import ( "encoding/json" "os" + "strings" "time" "github.com/sirupsen/logrus" @@ -35,8 +36,17 @@ var C = Config{ }, } +var defaultConfigFiles = []string{"/etc/matrix-bridge-meshtastic.json", "matrix-bridge-meshtastic.json"} + func Load() error { - for _, filename := range []string{"/etc/matrix-bridge-meshtastic.json", "matrix-bridge-meshtastic.json"} { + configFiles := defaultConfigFiles + + envConfigFiles := os.Getenv("MATRIX_BRIDGE_MESHTASTIC_CONFIG") + if envConfigFiles != "" { + configFiles = strings.Split(envConfigFiles, ",") + } + + for _, filename := range configFiles { err := load(filename) if err != nil && !os.IsNotExist(err) { return err