All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
41 lines
832 B
Go
41 lines
832 B
Go
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"`
|
|
TopicMappings []struct {
|
|
Id string `json:"id"`
|
|
Topics []string `json:"topics"`
|
|
Handler string `json:"handler"`
|
|
Config HandlerConfigT `json:"config"`
|
|
} `json:"topicMappings"`
|
|
Archiver struct {
|
|
Dir string `json:"dir"`
|
|
}
|
|
}
|
|
|
|
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)
|
|
}
|
|
|
|
Config.Mqtt.Password = os.Getenv("MQTT_PASSWORD")
|
|
}
|
|
|