move config validation into a separate function
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
package defaults
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strings"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/ocs/pkg/config"
|
||||
@@ -9,10 +8,8 @@ import (
|
||||
|
||||
func FullDefaultConfig() *config.Config {
|
||||
cfg := DefaultConfig()
|
||||
|
||||
EnsureDefaults(cfg)
|
||||
Sanitize(cfg)
|
||||
|
||||
return cfg
|
||||
}
|
||||
|
||||
@@ -91,8 +88,6 @@ func EnsureDefaults(cfg *config.Config) {
|
||||
|
||||
if cfg.MachineAuthAPIKey == "" && cfg.Commons != nil && cfg.Commons.MachineAuthAPIKey != "" {
|
||||
cfg.MachineAuthAPIKey = cfg.Commons.MachineAuthAPIKey
|
||||
} else if cfg.MachineAuthAPIKey == "" {
|
||||
log.Fatalf("machine auth api key is not set up properly, bailing out (%s)", cfg.Service.Name)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,6 +2,7 @@ package parser
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"github.com/owncloud/ocis/extensions/ocs/pkg/config"
|
||||
"github.com/owncloud/ocis/extensions/ocs/pkg/config/defaults"
|
||||
@@ -29,5 +30,12 @@ func ParseConfig(cfg *config.Config) error {
|
||||
|
||||
defaults.Sanitize(cfg)
|
||||
|
||||
return Validate(cfg)
|
||||
}
|
||||
|
||||
func Validate(cfg *config.Config) error {
|
||||
if cfg.MachineAuthAPIKey == "" {
|
||||
return fmt.Errorf("machine auth api key is not set up properly, bailing out (%s)", cfg.Service.Name)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user