move config validation into a separate function

This commit is contained in:
Willy Kloucek
2022-04-28 11:10:39 +02:00
parent df53c2a545
commit 3054875a05
64 changed files with 189 additions and 101 deletions
@@ -1,7 +1,6 @@
package defaults
import (
"log"
"path"
"strings"
@@ -188,8 +187,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)
}
if cfg.Reva == nil && cfg.Commons != nil && cfg.Commons.Reva != nil {
@@ -2,6 +2,7 @@ package parser
import (
"errors"
"fmt"
"github.com/owncloud/ocis/extensions/proxy/pkg/config"
"github.com/owncloud/ocis/extensions/proxy/pkg/config/defaults"
@@ -28,5 +29,13 @@ 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
}