allow env overriding config file path
All checks were successful
/ build-container (push) Successful in 1m48s
All checks were successful
/ build-container (push) Successful in 1m48s
This commit is contained in:
parent
b1b518e146
commit
e58fbcba5c
1 changed files with 11 additions and 1 deletions
|
@ -3,6 +3,7 @@ package config
|
||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"os"
|
"os"
|
||||||
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/sirupsen/logrus"
|
"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 {
|
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)
|
err := load(filename)
|
||||||
if err != nil && !os.IsNotExist(err) {
|
if err != nil && !os.IsNotExist(err) {
|
||||||
return err
|
return err
|
||||||
|
|
Loading…
Reference in a new issue