suporte a dynamic dns
This commit is contained in:
@@ -17,6 +17,17 @@ type Config struct {
|
||||
PDNSAPIKey string `yaml:"pdns_api_key" env:"PDNS_API_KEY"`
|
||||
PDNSServerID string `yaml:"pdns_server_id" env:"PDNS_SERVER_ID" env-default:"localhost"`
|
||||
Auth AuthConfig `yaml:"auth"`
|
||||
Database Database `yaml:"database"`
|
||||
}
|
||||
|
||||
// Database contains application database configuration.
|
||||
type Database struct {
|
||||
MySQL MySQLDatabase `yaml:"mysql"`
|
||||
}
|
||||
|
||||
// MySQLDatabase contains MySQL connection settings.
|
||||
type MySQLDatabase struct {
|
||||
DSN string `yaml:"dsn" env:"DATABASE_MYSQL_DSN"`
|
||||
}
|
||||
|
||||
type AuthConfig struct {
|
||||
@@ -63,6 +74,9 @@ func LoadFile(path string) (Config, error) {
|
||||
if cfg.PDNSAPIKey == "" {
|
||||
return Config{}, errors.New("PDNS_API_KEY is required")
|
||||
}
|
||||
if cfg.Database.MySQL.DSN == "" {
|
||||
return Config{}, errors.New("DATABASE_MYSQL_DSN is required")
|
||||
}
|
||||
if err := validateAuth(cfg.Auth); err != nil {
|
||||
return Config{}, err
|
||||
}
|
||||
@@ -113,6 +127,7 @@ func normalize(cfg *Config) {
|
||||
cfg.PDNSAPIURL = strings.TrimSpace(cfg.PDNSAPIURL)
|
||||
cfg.PDNSAPIKey = strings.TrimSpace(cfg.PDNSAPIKey)
|
||||
cfg.PDNSServerID = strings.TrimSpace(cfg.PDNSServerID)
|
||||
cfg.Database.MySQL.DSN = strings.TrimSpace(cfg.Database.MySQL.DSN)
|
||||
cfg.Auth.LDAP.URL = strings.TrimSpace(cfg.Auth.LDAP.URL)
|
||||
cfg.Auth.LDAP.BindDN = strings.TrimSpace(cfg.Auth.LDAP.BindDN)
|
||||
cfg.Auth.LDAP.BindPassword = strings.TrimSpace(cfg.Auth.LDAP.BindPassword)
|
||||
|
||||
Reference in New Issue
Block a user