config
This commit is contained in:
35
src/udi/config/config.go
Normal file
35
src/udi/config/config.go
Normal file
@ -0,0 +1,35 @@
|
||||
package config
|
||||
|
||||
import "encoding/json"
|
||||
import "log"
|
||||
import "os"
|
||||
|
||||
|
||||
type ConfigT struct {
|
||||
Mqtt struct {
|
||||
Broker string
|
||||
Username string
|
||||
Password string
|
||||
TlsEnable string
|
||||
}
|
||||
TopicMappings []struct {
|
||||
Topics []string
|
||||
Plugin string
|
||||
}
|
||||
Plugins []struct {
|
||||
Name string
|
||||
DatabaseConnStr string
|
||||
Attributes map[string]interface{}
|
||||
}
|
||||
}
|
||||
|
||||
var Config ConfigT
|
||||
|
||||
|
||||
func LoadConfiguration() {
|
||||
err := json.Unmarshal([]byte(os.Getenv("UDI_CONF")), &Config)
|
||||
if err != nil {
|
||||
log.Fatalf("Unable to parse configuration: %s", err)
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user