initial
This commit is contained in:
33
src/ma/config/config.go
Normal file
33
src/ma/config/config.go
Normal file
@ -0,0 +1,33 @@
|
||||
package config
|
||||
|
||||
import "encoding/json"
|
||||
import "log"
|
||||
import "os"
|
||||
|
||||
type HandlerConfigT struct {
|
||||
Attributes map[string]string `json:"attributes"`
|
||||
}
|
||||
|
||||
type ConfigT struct {
|
||||
Mqtt struct {
|
||||
Broker string `json:"broker"`
|
||||
Username string `json:"username"`
|
||||
Password string
|
||||
TlsEnable string `json:"tlsEnable"`
|
||||
} `json:"mqtt"`
|
||||
IncludeTopics []string `json:"includeTopics"`
|
||||
ExcludeTopics []string `json:"excludeTopics"`
|
||||
}
|
||||
|
||||
var Config ConfigT
|
||||
|
||||
|
||||
func LoadConfiguration() {
|
||||
err := json.Unmarshal([]byte(os.Getenv("MA_CONF")), &Config)
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to parse configuration: %s", err)
|
||||
}
|
||||
|
||||
Config.Mqtt.Password = os.Getenv("MQTT_PASSWORD")
|
||||
}
|
||||
|
Reference in New Issue
Block a user