diff --git a/pkg/service/v0/service.go b/pkg/service/v0/service.go index 2b1fd61905..682e51dbcf 100644 --- a/pkg/service/v0/service.go +++ b/pkg/service/v0/service.go @@ -8,14 +8,23 @@ import ( "github.com/owncloud/ocis-accounts/pkg/account" "github.com/owncloud/ocis-accounts/pkg/config" "github.com/owncloud/ocis-accounts/pkg/proto/v0" + olog "github.com/owncloud/ocis-pkg/log" ) // New returns a new instance of Service func New(cfg *config.Config) Service { - return Service{ - Config: cfg, - Manager: account.Registry[cfg.Manager](cfg), + s := Service{ + Config: cfg, } + + if newReg, ok := account.Registry[cfg.Manager]; ok { + s.Manager = newReg(cfg) + } else { + l := olog.NewLogger(olog.Name("ocis-accounts")) + l.Fatal().Msgf("driver does not exist: %v", cfg.Manager) + } + + return s } // Service implements the SettingsServiceHandler interface diff --git a/pkg/store/filesystem/store.go b/pkg/store/filesystem/store.go index 9c98d9c8bc..a4a5a09d41 100644 --- a/pkg/store/filesystem/store.go +++ b/pkg/store/filesystem/store.go @@ -14,10 +14,8 @@ import ( var ( // StoreName is the default name for the accounts store - StoreName string = "ocis-store" - - // managerName - managerName = "filesystem" + StoreName string = "ocis-store" + managerName = "filesystem" ) // StoreName is the default name for the store container @@ -31,7 +29,7 @@ type Store struct { // New creates a new store func New(cfg *config.Config) account.Manager { s := Store{ - Logger: olog.NewLogger(), + Logger: olog.NewLogger(olog.Name("ocis-accounts")), } dest := filepath.Join(cfg.MountPath, StoreName) @@ -96,6 +94,7 @@ func (s Store) Write(rec *account.Record) *account.Record { s.Logger.Info().Msgf("%v bytes written to %v", len(rec.Value), path) return rec } + func init() { account.Registry[managerName] = New }