move accounts config sanitazing into config parsing

This commit is contained in:
Willy Kloucek
2021-12-17 16:58:36 +01:00
parent 2bcd4f5a17
commit b70cbd26ee
2 changed files with 7 additions and 7 deletions

View File

@@ -3,6 +3,7 @@ package command
import (
"context"
"os"
"strings"
"github.com/owncloud/ocis/accounts/pkg/config"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
@@ -82,6 +83,12 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
return err
}
// sanitize config
if cfg.HTTP.Root != "/" {
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
}
cfg.Repo.Backend = strings.ToLower(cfg.Repo.Backend)
return nil
}

View File

@@ -2,7 +2,6 @@ package command
import (
"context"
"strings"
"github.com/oklog/run"
"github.com/owncloud/ocis/accounts/pkg/config"
@@ -22,16 +21,10 @@ func Server(cfg *config.Config) *cli.Command {
Usage: "Start ocis accounts service",
Description: "uses an LDAP server as the storage backend",
Before: func(ctx *cli.Context) error {
if cfg.HTTP.Root != "/" {
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
}
if err := ParseConfig(ctx, cfg); err != nil {
return err
}
cfg.Repo.Backend = strings.ToLower(cfg.Repo.Backend)
return nil
},
Action: func(c *cli.Context) error {