ensure lowercase backend in the command

This commit is contained in:
Willy Kloucek
2021-10-27 12:53:25 +02:00
parent 405809f13a
commit ef406c8baa
2 changed files with 7 additions and 5 deletions

View File

@@ -30,6 +30,8 @@ func Server(cfg *config.Config) *cli.Command {
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
}
cfg.Repo.Backend = strings.ToLower(cfg.Repo.Backend)
// When running on single binary mode the before hook from the root command won't get called. We manually
// call this before hook from ocis command, so the configuration can be loaded.
if !cfg.Supervised {

View File

@@ -64,7 +64,7 @@ func New(opts ...Option) (s *Service, err error) {
}
r := oreg.GetRegistry()
if strings.ToLower(cfg.Repo.Backend) == "cs3" {
if cfg.Repo.Backend == "cs3" {
if _, err := r.GetService("com.owncloud.storage.metadata"); err != nil {
logger.Error().Err(err).Msg("index: storage-metadata service not present")
return nil, err
@@ -119,17 +119,17 @@ func configFromSvc(cfg *config.Config) (*idxcfg.Config, error) {
}
}(cfg)
switch backend := strings.ToLower(cfg.Repo.Backend); backend {
switch cfg.Repo.Backend {
case "disk":
c.Repo = idxcfg.Repo{
Backend: backend,
Backend: cfg.Repo.Backend,
Disk: idxcfg.Disk{
Path: cfg.Repo.Disk.Path,
},
}
case "cs3":
c.Repo = idxcfg.Repo{
Backend: backend,
Backend: cfg.Repo.Backend,
CS3: idxcfg.CS3{
ProviderAddr: cfg.Repo.CS3.ProviderAddr,
DataURL: cfg.Repo.CS3.DataURL,
@@ -425,7 +425,7 @@ func (s Service) createDefaultGroups(withDemoGroups bool) (err error) {
}
func createMetadataStorage(cfg *config.Config, logger log.Logger) (storage.Repo, error) {
switch strings.ToLower(cfg.Repo.Backend) {
switch cfg.Repo.Backend {
case "disk":
return storage.NewDiskRepo(cfg, logger), nil
case "cs3":