Removing logging, return errors and check types

This commit is contained in:
Andrew Morgan (https://amorgan.xyz) 2017-12-18 11:04:03 -08:00
parent 0a8d2325d3
commit 904b586e65
No known key found for this signature in database
GPG key ID: 174BEAB009FD176D
3 changed files with 12 additions and 7 deletions

View file

@ -123,4 +123,4 @@ tracing:
# A list of application service config files to use
applicationservice:
app_service_config_files:
app_service_config_files: []

View file

@ -44,7 +44,7 @@ type ApplicationService struct {
// Localpart of application service user
SenderLocalpart string `yaml:"sender_localpart"`
// Information about an application service's namespaces
Namespaces map[string][]interface{} `yaml:"namespaces"`
Namespaces map[string][]ApplicationServiceNamespace `yaml:"namespaces"`
}
func loadAppservices(config *Dendrite) error {

View file

@ -334,7 +334,8 @@ func loadConfig(
for _, certPath := range config.Matrix.FederationCertificatePaths {
absCertPath := absPath(basePath, certPath)
pemData, err := readFile(absCertPath)
var pemData []byte
pemData, err = readFile(absCertPath)
if err != nil {
return nil, err
}
@ -348,14 +349,17 @@ func loadConfig(
config.Media.AbsBasePath = Path(absPath(basePath, config.Media.BasePath))
// Generate data from config options
config.derive()
err = config.derive()
if err != nil {
return nil, err
}
return &config, nil
}
// derive generates data that is derived from various values provided in
// the config file.
func (config *Dendrite) derive() {
func (config *Dendrite) derive() error {
// Determine registrations flows based off config values
config.Derived.Registration.Params = make(map[string]interface{})
@ -373,12 +377,13 @@ func (config *Dendrite) derive() {
}
// Load application service configuration files
fmt.Println(config.ApplicationService.ConfigFiles)
if len(config.ApplicationService.ConfigFiles) > 0 {
if err := loadAppservices(config); err != nil {
fmt.Println("Error loading AS config: ", err)
return err
}
}
return nil
}
// setDefaults sets default config values if they are not explicitly set.