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)
  }
}

