|
@@ -1,56 +1,90 @@
|
|
|
package config
|
|
|
|
|
|
+import (
|
|
|
+ "io/ioutil"
|
|
|
+
|
|
|
+ yaml "gopkg.in/yaml.v2"
|
|
|
+)
|
|
|
+
|
|
|
const (
|
|
|
LOG_LEVEL_OFF = iota
|
|
|
LOG_LEVEL_INFO
|
|
|
LOG_LEVEL_DEBUG
|
|
|
)
|
|
|
|
|
|
-var (
|
|
|
- // Database
|
|
|
+type ConfigT struct {
|
|
|
|
|
|
- DBConnection = "root:password@tcp(localhost:3306)/karmen_dev"
|
|
|
- DBConnectionOpts = "charset=utf8&parseTime=True&loc=Local"
|
|
|
- ResetOnBoot = false
|
|
|
- AutoMigrateOnBoot = true
|
|
|
- RegenerateOnBoot = false
|
|
|
+ // Domain
|
|
|
|
|
|
- AdminUsername = "admin"
|
|
|
- AdminPassword = "admin"
|
|
|
+ Domain string
|
|
|
|
|
|
- Domain = "foo.org"
|
|
|
+ // Logging
|
|
|
|
|
|
- // LDAP
|
|
|
+ LogLevel int `yaml:"log_level"`
|
|
|
|
|
|
- LDAPHostAddress = "localhost"
|
|
|
- LDAPHostPort = 389
|
|
|
- LDAPBindPassword = "admin"
|
|
|
- LDAPBindUser = "cn=admin,dc=foo,dc=org"
|
|
|
- LDAPRootDN = "dc=foo,dc=org"
|
|
|
+ // Admin credentials
|
|
|
|
|
|
- LDAPPeopleOU = "Persone"
|
|
|
- LDAPTeacherOU = "Docenti"
|
|
|
- LDAPGroupsOU = "Gruppi"
|
|
|
- LDAPTeachersGroupOU = "Docenti"
|
|
|
+ Admin struct {
|
|
|
+ Username string
|
|
|
+ Password string
|
|
|
+ }
|
|
|
|
|
|
- // LimeSurvey Remote Control URL
|
|
|
-
|
|
|
- LSAPIRemoteControlUrl = "http://localhost:8081/index.php/admin/remotecontrol"
|
|
|
- LSAPIUsername = "admin"
|
|
|
- LSAPIPassword = "password"
|
|
|
+ // Database
|
|
|
|
|
|
- // WebDAV
|
|
|
+ Orm struct {
|
|
|
+ Connection string
|
|
|
+ Options string
|
|
|
+ Reset bool
|
|
|
+ AutoMigrate bool
|
|
|
+ Regenerate bool
|
|
|
+ }
|
|
|
|
|
|
- WebDAVUrl = "http://localhost:8082/remote.php/webdav/"
|
|
|
- WebDavUsername = "admin"
|
|
|
- WebDAVPassword = "password"
|
|
|
+ // LDAP
|
|
|
|
|
|
- // Document generator
|
|
|
+ Ldap struct {
|
|
|
+ Host string
|
|
|
+ Port string
|
|
|
+ BindPassword string `yaml:"bind_password"`
|
|
|
+ BindUser string `yaml:"bind_user"`
|
|
|
+ RootDN string `yaml:"root_dn"`
|
|
|
|
|
|
- DocumentRootDir = "documents/"
|
|
|
- DocumentConfigFn = "config.yaml"
|
|
|
+ OuPeople string `yaml:"ou_people"`
|
|
|
+ OuTeacher string `yaml:"ou_teacher"`
|
|
|
+ OuGroup string `yaml:"ou_group"`
|
|
|
+ OuTeachersGroup string `yaml:"ou_teachers_group"`
|
|
|
+ }
|
|
|
|
|
|
- // Logging
|
|
|
+ // LimeSurvey Remote Control URL
|
|
|
|
|
|
- LogLevel = LOG_LEVEL_DEBUG
|
|
|
-)
|
|
|
+ Limesurvey struct {
|
|
|
+ Url string
|
|
|
+ Username string
|
|
|
+ Password string
|
|
|
+ }
|
|
|
+
|
|
|
+ // Cloud
|
|
|
+
|
|
|
+ Cloud struct {
|
|
|
+ Url string
|
|
|
+ Username string
|
|
|
+ Password string
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
+var Config *ConfigT
|
|
|
+
|
|
|
+func init() {
|
|
|
+ Config = new(ConfigT)
|
|
|
+}
|
|
|
+
|
|
|
+// Load loads the config file placed at the given path.
|
|
|
+func Load(path string, config *ConfigT) error {
|
|
|
+ cf, err := ioutil.ReadFile(path)
|
|
|
+ if err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ if err := yaml.Unmarshal(cf, config); err != nil {
|
|
|
+ return err
|
|
|
+ }
|
|
|
+ return nil
|
|
|
+}
|