patch config parsing

This commit is contained in:
A.Unger
2021-03-05 14:08:40 +01:00
parent bb2431839d
commit 277ccc8b82
12 changed files with 38 additions and 27 deletions

View File

@@ -109,7 +109,7 @@ func (r *Runtime) Start() error {
r.c.Storage.Log.Pretty = r.c.Log.Pretty
addServiceToken("settings", supervisor.Add(settings.NewSutureService(globalCtx, r.c.Settings)))
addServiceToken("storage-metadata", supervisor.Add(storage.NewStorageMetadata(globalCtx, r.c.Storage)))
addServiceToken("storage-metadata", supervisor.Add(storage.NewStorageMetadata(globalCtx)))
addServiceToken("accounts", supervisor.Add(accounts.NewSutureService(globalCtx, r.c.Accounts)))
addServiceToken("glauth", supervisor.Add(glauth.NewSutureService(globalCtx, r.c.GLAuth)))
addServiceToken("idp", supervisor.Add(idp.NewSutureService(globalCtx, r.c.IDP)))
@@ -120,16 +120,16 @@ func (r *Runtime) Start() error {
addServiceToken("thumbnails", supervisor.Add(thumbnails.NewSutureService(globalCtx, r.c.Thumbnails)))
addServiceToken("web", supervisor.Add(web.NewSutureService(globalCtx, r.c.Web)))
addServiceToken("webdav", supervisor.Add(webdav.NewSutureService(globalCtx, r.c.WebDAV)))
addServiceToken("storage-frontend", supervisor.Add(storage.NewFrontend(globalCtx, r.c.Storage)))
addServiceToken("storage-gateway", supervisor.Add(storage.NewGateway(globalCtx, r.c.Storage)))
addServiceToken("storage-users", supervisor.Add(storage.NewUsersProviderService(globalCtx, r.c.Storage)))
addServiceToken("storage-groupsprovider", supervisor.Add(storage.NewGroupsProvider(globalCtx, r.c.Storage))) // TODO(refs) panic? are we sending to a nil / closed channel?
addServiceToken("storage-authbasic", supervisor.Add(storage.NewAuthBasic(globalCtx, r.c.Storage)))
addServiceToken("storage-authbearer", supervisor.Add(storage.NewAuthBearer(globalCtx, r.c.Storage)))
addServiceToken("storage-home", supervisor.Add(storage.NewStorageHome(globalCtx, r.c.Storage)))
addServiceToken("storage-users", supervisor.Add(storage.NewStorageUsers(globalCtx, r.c.Storage)))
addServiceToken("storage-public-link", supervisor.Add(storage.NewStoragePublicLink(globalCtx, r.c.Storage)))
addServiceToken("storage-sharing", supervisor.Add(storage.NewSharing(globalCtx, r.c.Storage)))
addServiceToken("storage-frontend", supervisor.Add(storage.NewFrontend(globalCtx)))
addServiceToken("storage-gateway", supervisor.Add(storage.NewGateway(globalCtx)))
addServiceToken("storage-users", supervisor.Add(storage.NewUsersProviderService(globalCtx)))
addServiceToken("storage-groupsprovider", supervisor.Add(storage.NewGroupsProvider(globalCtx))) // TODO(refs) panic? are we sending to a nil / closed channel?
addServiceToken("storage-authbasic", supervisor.Add(storage.NewAuthBasic(globalCtx)))
addServiceToken("storage-authbearer", supervisor.Add(storage.NewAuthBearer(globalCtx)))
addServiceToken("storage-home", supervisor.Add(storage.NewStorageHome(globalCtx)))
addServiceToken("storage-users", supervisor.Add(storage.NewStorageUsers(globalCtx)))
addServiceToken("storage-public-link", supervisor.Add(storage.NewStoragePublicLink(globalCtx)))
addServiceToken("storage-sharing", supervisor.Add(storage.NewSharing(globalCtx)))
// TODO(refs) debug line with supervised services.
go supervisor.ServeBackground()

View File

@@ -70,7 +70,7 @@ func AuthBasic(cfg *config.Config) *cli.Command {
// precreate folders
if cfg.Reva.AuthProvider.Driver == "json" && cfg.Reva.AuthProvider.JSON != "" {
if err := os.MkdirAll(filepath.Dir(cfg.Reva.AuthProvider.JSON), os.ModeExclusive); err != nil {
if err := os.MkdirAll(filepath.Dir(cfg.Reva.AuthProvider.JSON), os.FileMode(0700)); err != nil {
return err
}
}
@@ -208,8 +208,9 @@ type AuthBasicSutureService struct {
}
// NewAuthBasicSutureService creates a new store.AuthBasicSutureService
func NewAuthBasic(ctx context.Context, cfg *config.Config) AuthBasicSutureService {
func NewAuthBasic(ctx context.Context) AuthBasicSutureService {
sctx, cancel := context.WithCancel(ctx)
cfg := config.New()
cfg.Context = sctx
return AuthBasicSutureService{
ctx: sctx,

View File

@@ -188,8 +188,9 @@ type AuthBearerSutureService struct {
}
// NewAuthBearerSutureService creates a new gateway.AuthBearerSutureService
func NewAuthBearer(ctx context.Context, cfg *config.Config) AuthBearerSutureService {
func NewAuthBearer(ctx context.Context) AuthBearerSutureService {
sctx, cancel := context.WithCancel(ctx)
cfg := config.New()
cfg.Context = sctx
return AuthBearerSutureService{
ctx: sctx,

View File

@@ -336,8 +336,9 @@ type FrontendSutureService struct {
}
// NewFrontendSutureService creates a new frontend.FrontendSutureService
func NewFrontend(ctx context.Context, cfg *config.Config) FrontendSutureService {
func NewFrontend(ctx context.Context) FrontendSutureService {
sctx, cancel := context.WithCancel(ctx)
cfg := config.New()
cfg.Context = sctx
return FrontendSutureService{
ctx: sctx,

View File

@@ -265,8 +265,9 @@ type GatewaySutureService struct {
}
// NewGatewaySutureService creates a new gateway.GatewaySutureService
func NewGateway(ctx context.Context, cfg *config.Config) GatewaySutureService {
func NewGateway(ctx context.Context) GatewaySutureService {
sctx, cancel := context.WithCancel(ctx)
cfg := config.New()
cfg.Context = sctx
return GatewaySutureService{
ctx: sctx,

View File

@@ -70,7 +70,7 @@ func Groups(cfg *config.Config) *cli.Command {
// precreate folders
if cfg.Reva.Groups.Driver == "json" && cfg.Reva.Groups.JSON != "" {
if err := os.MkdirAll(filepath.Dir(cfg.Reva.Groups.JSON), os.ModeExclusive); err != nil {
if err := os.MkdirAll(filepath.Dir(cfg.Reva.Groups.JSON), os.FileMode(0700)); err != nil {
return err
}
}
@@ -222,8 +222,9 @@ type GroupsProvider struct {
}
// NewGroupsProvider creates a new storage.GroupsProvider
func NewGroupsProvider(ctx context.Context, cfg *config.Config) GroupsProvider {
func NewGroupsProvider(ctx context.Context) GroupsProvider {
sctx, cancel := context.WithCancel(ctx)
cfg := config.New()
cfg.Context = sctx
return GroupsProvider{
ctx: sctx,

View File

@@ -70,12 +70,12 @@ func Sharing(cfg *config.Config) *cli.Command {
// precreate folders
if cfg.Reva.Sharing.UserDriver == "json" && cfg.Reva.Sharing.UserJSONFile != "" {
if err := os.MkdirAll(filepath.Dir(cfg.Reva.Sharing.UserJSONFile), os.ModeExclusive); err != nil {
if err := os.MkdirAll(filepath.Dir(cfg.Reva.Sharing.UserJSONFile), os.FileMode(0700)); err != nil {
return err
}
}
if cfg.Reva.Sharing.PublicDriver == "json" && cfg.Reva.Sharing.PublicJSONFile != "" {
if err := os.MkdirAll(filepath.Dir(cfg.Reva.Sharing.PublicJSONFile), os.ModeExclusive); err != nil {
if err := os.MkdirAll(filepath.Dir(cfg.Reva.Sharing.PublicJSONFile), os.FileMode(0700)); err != nil {
return err
}
}
@@ -211,8 +211,9 @@ type SharingSutureService struct {
}
// NewSharingSutureService creates a new store.SharingSutureService
func NewSharing(ctx context.Context, cfg *config.Config) SharingSutureService {
func NewSharing(ctx context.Context) SharingSutureService {
sctx, cancel := context.WithCancel(ctx)
cfg := config.New()
cfg.Context = sctx
return SharingSutureService{
ctx: sctx,

View File

@@ -207,8 +207,9 @@ type StorageHomeSutureService struct {
}
// NewStorageHomeSutureService creates a new storage.StorageHomeSutureService
func NewStorageHome(ctx context.Context, cfg *config.Config) StorageHomeSutureService {
func NewStorageHome(ctx context.Context) StorageHomeSutureService {
sctx, cancel := context.WithCancel(ctx)
cfg := config.New()
cfg.Context = sctx
return StorageHomeSutureService{
ctx: sctx,

View File

@@ -228,8 +228,9 @@ type SutureService struct {
}
// NewSutureService creates a new storagemetadata.SutureService
func NewStorageMetadata(ctx context.Context, cfg *config.Config) SutureService {
func NewStorageMetadata(ctx context.Context) SutureService {
sctx, cancel := context.WithCancel(ctx)
cfg := config.New()
cfg.Context = sctx
return SutureService{
ctx: sctx,

View File

@@ -185,8 +185,9 @@ type StoragePublicLinkSutureService struct {
}
// NewStoragePublicLinkSutureService creates a new storage.StoragePublicLinkSutureService
func NewStoragePublicLink(ctx context.Context, cfg *config.Config) StoragePublicLinkSutureService {
func NewStoragePublicLink(ctx context.Context) StoragePublicLinkSutureService {
sctx, cancel := context.WithCancel(ctx)
cfg := config.New()
cfg.Context = sctx
return StoragePublicLinkSutureService{
ctx: sctx,

View File

@@ -207,8 +207,9 @@ type StorageUsersSutureService struct {
}
// NewStorageUsersSutureService creates a new storage.StorageUsersSutureService
func NewStorageUsers(ctx context.Context, cfg *config.Config) StorageUsersSutureService {
func NewStorageUsers(ctx context.Context) StorageUsersSutureService {
sctx, cancel := context.WithCancel(ctx)
cfg := config.New()
cfg.Context = sctx
return StorageUsersSutureService{
ctx: sctx,

View File

@@ -70,7 +70,7 @@ func Users(cfg *config.Config) *cli.Command {
// precreate folders
if cfg.Reva.Users.Driver == "json" && cfg.Reva.Users.JSON != "" {
if err := os.MkdirAll(filepath.Dir(cfg.Reva.Users.JSON), os.ModeExclusive); err != nil {
if err := os.MkdirAll(filepath.Dir(cfg.Reva.Users.JSON), os.FileMode(0700)); err != nil {
return err
}
}
@@ -223,8 +223,9 @@ type UsersProviderService struct {
}
// NewUsersProviderService creates a new storage.UsersProviderService
func NewUsersProviderService(ctx context.Context, cfg *config.Config) UsersProviderService {
func NewUsersProviderService(ctx context.Context) UsersProviderService {
sctx, cancel := context.WithCancel(ctx)
cfg := config.New()
cfg.Context = sctx
return UsersProviderService{
ctx: sctx,