From 904b586e65e7965b372e8d22b4119e0aef2a2435 Mon Sep 17 00:00:00 2001 From: "Andrew Morgan (https://amorgan.xyz)" Date: Mon, 18 Dec 2017 11:04:03 -0800 Subject: [PATCH] Removing logging, return errors and check types --- dendrite-config.yaml | 2 +- .../dendrite/common/config/appservice.go | 2 +- .../matrix-org/dendrite/common/config/config.go | 15 ++++++++++----- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/dendrite-config.yaml b/dendrite-config.yaml index 394e27757..d5e0a6369 100644 --- a/dendrite-config.yaml +++ b/dendrite-config.yaml @@ -123,4 +123,4 @@ tracing: # A list of application service config files to use applicationservice: - app_service_config_files: + app_service_config_files: [] diff --git a/src/github.com/matrix-org/dendrite/common/config/appservice.go b/src/github.com/matrix-org/dendrite/common/config/appservice.go index ee513c9fc..217c11967 100644 --- a/src/github.com/matrix-org/dendrite/common/config/appservice.go +++ b/src/github.com/matrix-org/dendrite/common/config/appservice.go @@ -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 { diff --git a/src/github.com/matrix-org/dendrite/common/config/config.go b/src/github.com/matrix-org/dendrite/common/config/config.go index 2b8357648..fe4fce0d3 100644 --- a/src/github.com/matrix-org/dendrite/common/config/config.go +++ b/src/github.com/matrix-org/dendrite/common/config/config.go @@ -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.