correctly implement suture v4 interfaces
This commit is contained in:
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/owncloud/ocis/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/storage/pkg/flagset"
|
||||
"github.com/owncloud/ocis/storage/pkg/server/debug"
|
||||
"github.com/thejerf/suture"
|
||||
"github.com/thejerf/suture/v4"
|
||||
)
|
||||
|
||||
// AuthBasic is the entrypoint for the auth-basic command.
|
||||
@@ -172,43 +172,36 @@ func AuthBasic(cfg *config.Config) *cli.Command {
|
||||
|
||||
// AuthBasicSutureService allows for the storage-authbasic command to be embedded and supervised by a suture supervisor tree.
|
||||
type AuthBasicSutureService struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc // used to cancel the context go-micro services used to shutdown a service.
|
||||
cfg *config.Config
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewAuthBasicSutureService creates a new store.AuthBasicSutureService
|
||||
func NewAuthBasic(ctx context.Context, cfg *ociscfg.Config) suture.Service {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Storage.Reva.AuthBasic.Context = sctx
|
||||
func NewAuthBasic(cfg *ociscfg.Config) suture.Service {
|
||||
if cfg.Mode == 0 {
|
||||
cfg.Storage.Reva.AuthBasic.Supervised = true
|
||||
}
|
||||
return AuthBasicSutureService{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg.Storage,
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
}
|
||||
|
||||
func (s AuthBasicSutureService) Serve() {
|
||||
func (s AuthBasicSutureService) Serve(ctx context.Context) error {
|
||||
s.cfg.Reva.AuthBasic.Context = ctx
|
||||
f := &flag.FlagSet{}
|
||||
for k := range AuthBasic(s.cfg).Flags {
|
||||
if err := AuthBasic(s.cfg).Flags[k].Apply(f); err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
}
|
||||
ctx := cli.NewContext(nil, f, nil)
|
||||
cliCtx := cli.NewContext(nil, f, nil)
|
||||
if AuthBasic(s.cfg).Before != nil {
|
||||
if err := AuthBasic(s.cfg).Before(ctx); err != nil {
|
||||
return
|
||||
if err := AuthBasic(s.cfg).Before(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := AuthBasic(s.cfg).Action(ctx); err != nil {
|
||||
return
|
||||
if err := AuthBasic(s.cfg).Action(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s AuthBasicSutureService) Stop() {
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/owncloud/ocis/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/storage/pkg/flagset"
|
||||
"github.com/owncloud/ocis/storage/pkg/server/debug"
|
||||
"github.com/thejerf/suture"
|
||||
"github.com/thejerf/suture/v4"
|
||||
)
|
||||
|
||||
// AuthBearer is the entrypoint for the auth-bearer command.
|
||||
@@ -152,43 +152,36 @@ func AuthBearer(cfg *config.Config) *cli.Command {
|
||||
|
||||
// AuthBearerSutureService allows for the storage-gateway command to be embedded and supervised by a suture supervisor tree.
|
||||
type AuthBearerSutureService struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc // used to cancel the context go-micro services used to shutdown a service.
|
||||
cfg *config.Config
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewAuthBearerSutureService creates a new gateway.AuthBearerSutureService
|
||||
func NewAuthBearer(ctx context.Context, cfg *ociscfg.Config) suture.Service {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Storage.Reva.AuthBearer.Context = sctx
|
||||
func NewAuthBearer(cfg *ociscfg.Config) suture.Service {
|
||||
if cfg.Mode == 0 {
|
||||
cfg.Storage.Reva.AuthBearer.Supervised = true
|
||||
}
|
||||
return AuthBearerSutureService{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg.Storage,
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
}
|
||||
|
||||
func (s AuthBearerSutureService) Serve() {
|
||||
func (s AuthBearerSutureService) Serve(ctx context.Context) error {
|
||||
s.cfg.Reva.AuthBearer.Context = ctx
|
||||
f := &flag.FlagSet{}
|
||||
for k := range AuthBearer(s.cfg).Flags {
|
||||
if err := AuthBearer(s.cfg).Flags[k].Apply(f); err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
}
|
||||
ctx := cli.NewContext(nil, f, nil)
|
||||
cliCtx := cli.NewContext(nil, f, nil)
|
||||
if AuthBearer(s.cfg).Before != nil {
|
||||
if err := AuthBearer(s.cfg).Before(ctx); err != nil {
|
||||
return
|
||||
if err := AuthBearer(s.cfg).Before(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := AuthBearer(s.cfg).Action(ctx); err != nil {
|
||||
return
|
||||
if err := AuthBearer(s.cfg).Action(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s AuthBearerSutureService) Stop() {
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ import (
|
||||
"github.com/owncloud/ocis/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/storage/pkg/flagset"
|
||||
"github.com/owncloud/ocis/storage/pkg/server/debug"
|
||||
"github.com/thejerf/suture"
|
||||
"github.com/thejerf/suture/v4"
|
||||
)
|
||||
|
||||
// Frontend is the entrypoint for the frontend command.
|
||||
@@ -305,43 +305,36 @@ func loadUserAgent(c *cli.Context, cfg *config.Config) error {
|
||||
|
||||
// FrontendSutureService allows for the storage-frontend command to be embedded and supervised by a suture supervisor tree.
|
||||
type FrontendSutureService struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc // used to cancel the context go-micro services used to shutdown a service.
|
||||
cfg *config.Config
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewFrontendSutureService creates a new frontend.FrontendSutureService
|
||||
func NewFrontend(ctx context.Context, cfg *ociscfg.Config) suture.Service {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Storage.Reva.Frontend.Context = sctx
|
||||
func NewFrontend(cfg *ociscfg.Config) suture.Service {
|
||||
if cfg.Mode == 0 {
|
||||
cfg.Storage.Reva.Frontend.Supervised = true
|
||||
}
|
||||
return FrontendSutureService{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg.Storage,
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
}
|
||||
|
||||
func (s FrontendSutureService) Serve() {
|
||||
func (s FrontendSutureService) Serve(ctx context.Context) error {
|
||||
s.cfg.Reva.Frontend.Context = ctx
|
||||
f := &flag.FlagSet{}
|
||||
for k := range Frontend(s.cfg).Flags {
|
||||
if err := Frontend(s.cfg).Flags[k].Apply(f); err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
}
|
||||
ctx := cli.NewContext(nil, f, nil)
|
||||
cliCtx := cli.NewContext(nil, f, nil)
|
||||
if Frontend(s.cfg).Before != nil {
|
||||
if err := Frontend(s.cfg).Before(ctx); err != nil {
|
||||
return
|
||||
if err := Frontend(s.cfg).Before(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := Frontend(s.cfg).Action(ctx); err != nil {
|
||||
return
|
||||
if err := Frontend(s.cfg).Action(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s FrontendSutureService) Stop() {
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import (
|
||||
"github.com/owncloud/ocis/storage/pkg/flagset"
|
||||
"github.com/owncloud/ocis/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/storage/pkg/service/external"
|
||||
"github.com/thejerf/suture"
|
||||
"github.com/thejerf/suture/v4"
|
||||
)
|
||||
|
||||
// Gateway is the entrypoint for the gateway command.
|
||||
@@ -230,43 +230,36 @@ func rules(cfg *config.Config) map[string]interface{} {
|
||||
|
||||
// GatewaySutureService allows for the storage-gateway command to be embedded and supervised by a suture supervisor tree.
|
||||
type GatewaySutureService struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc // used to cancel the context go-micro services used to shutdown a service.
|
||||
cfg *config.Config
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewGatewaySutureService creates a new gateway.GatewaySutureService
|
||||
func NewGateway(ctx context.Context, cfg *ociscfg.Config) suture.Service {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Storage.Reva.Gateway.Context = sctx
|
||||
func NewGateway(cfg *ociscfg.Config) suture.Service {
|
||||
if cfg.Mode == 0 {
|
||||
cfg.Storage.Reva.Gateway.Supervised = true
|
||||
}
|
||||
return GatewaySutureService{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg.Storage,
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
}
|
||||
|
||||
func (s GatewaySutureService) Serve() {
|
||||
func (s GatewaySutureService) Serve(ctx context.Context) error {
|
||||
s.cfg.Reva.Gateway.Context = ctx
|
||||
f := &flag.FlagSet{}
|
||||
for k := range Gateway(s.cfg).Flags {
|
||||
if err := Gateway(s.cfg).Flags[k].Apply(f); err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
}
|
||||
ctx := cli.NewContext(nil, f, nil)
|
||||
cliCtx := cli.NewContext(nil, f, nil)
|
||||
if Gateway(s.cfg).Before != nil {
|
||||
if err := Gateway(s.cfg).Before(ctx); err != nil {
|
||||
return
|
||||
if err := Gateway(s.cfg).Before(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := Gateway(s.cfg).Action(ctx); err != nil {
|
||||
return
|
||||
if err := Gateway(s.cfg).Action(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s GatewaySutureService) Stop() {
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/owncloud/ocis/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/storage/pkg/flagset"
|
||||
"github.com/owncloud/ocis/storage/pkg/server/debug"
|
||||
"github.com/thejerf/suture"
|
||||
"github.com/thejerf/suture/v4"
|
||||
)
|
||||
|
||||
// Groups is the entrypoint for the sharing command.
|
||||
@@ -187,43 +187,36 @@ func Groups(cfg *config.Config) *cli.Command {
|
||||
|
||||
// GroupsProvider allows for the storage-groupsprovider command to be embedded and supervised by a suture supervisor tree.
|
||||
type GroupsProvider struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc // used to cancel the context go-micro services used to shutdown a service.
|
||||
cfg *config.Config
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewGroupsProvider creates a new storage.GroupsProvider
|
||||
func NewGroupsProvider(ctx context.Context, cfg *ociscfg.Config) suture.Service {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Storage.Reva.Groups.Context = sctx
|
||||
func NewGroupsProvider(cfg *ociscfg.Config) suture.Service {
|
||||
if cfg.Mode == 0 {
|
||||
cfg.Storage.Reva.Groups.Supervised = true
|
||||
}
|
||||
return GroupsProvider{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg.Storage,
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
}
|
||||
|
||||
func (s GroupsProvider) Serve() {
|
||||
func (s GroupsProvider) Serve(ctx context.Context) error {
|
||||
s.cfg.Reva.Groups.Context = ctx
|
||||
f := &flag.FlagSet{}
|
||||
for k := range Groups(s.cfg).Flags {
|
||||
if err := Groups(s.cfg).Flags[k].Apply(f); err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
}
|
||||
ctx := cli.NewContext(nil, f, nil)
|
||||
cliCtx := cli.NewContext(nil, f, nil)
|
||||
if Groups(s.cfg).Before != nil {
|
||||
if err := Groups(s.cfg).Before(ctx); err != nil {
|
||||
return
|
||||
if err := Groups(s.cfg).Before(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := Groups(s.cfg).Action(ctx); err != nil {
|
||||
return
|
||||
if err := Groups(s.cfg).Action(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s GroupsProvider) Stop() {
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/owncloud/ocis/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/storage/pkg/flagset"
|
||||
"github.com/owncloud/ocis/storage/pkg/server/debug"
|
||||
"github.com/thejerf/suture"
|
||||
"github.com/thejerf/suture/v4"
|
||||
)
|
||||
|
||||
// Sharing is the entrypoint for the sharing command.
|
||||
@@ -180,43 +180,36 @@ func Sharing(cfg *config.Config) *cli.Command {
|
||||
|
||||
// SharingSutureService allows for the storage-sharing command to be embedded and supervised by a suture supervisor tree.
|
||||
type SharingSutureService struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc // used to cancel the context go-micro services used to shutdown a service.
|
||||
cfg *config.Config
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewSharingSutureService creates a new store.SharingSutureService
|
||||
func NewSharing(ctx context.Context, cfg *ociscfg.Config) suture.Service {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Storage.Reva.Sharing.Context = sctx
|
||||
func NewSharing(cfg *ociscfg.Config) suture.Service {
|
||||
if cfg.Mode == 0 {
|
||||
cfg.Storage.Reva.Sharing.Supervised = true
|
||||
}
|
||||
return SharingSutureService{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg.Storage,
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
}
|
||||
|
||||
func (s SharingSutureService) Serve() {
|
||||
func (s SharingSutureService) Serve(ctx context.Context) error {
|
||||
s.cfg.Reva.Sharing.Context = ctx
|
||||
f := &flag.FlagSet{}
|
||||
for k := range Sharing(s.cfg).Flags {
|
||||
if err := Sharing(s.cfg).Flags[k].Apply(f); err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
}
|
||||
ctx := cli.NewContext(nil, f, nil)
|
||||
cliCtx := cli.NewContext(nil, f, nil)
|
||||
if Sharing(s.cfg).Before != nil {
|
||||
if err := Sharing(s.cfg).Before(ctx); err != nil {
|
||||
return
|
||||
if err := Sharing(s.cfg).Before(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := Sharing(s.cfg).Action(ctx); err != nil {
|
||||
return
|
||||
if err := Sharing(s.cfg).Action(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s SharingSutureService) Stop() {
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/owncloud/ocis/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/storage/pkg/flagset"
|
||||
"github.com/owncloud/ocis/storage/pkg/server/debug"
|
||||
"github.com/thejerf/suture"
|
||||
"github.com/thejerf/suture/v4"
|
||||
)
|
||||
|
||||
// StorageHome is the entrypoint for the storage-home command.
|
||||
@@ -172,43 +172,36 @@ func StorageHome(cfg *config.Config) *cli.Command {
|
||||
|
||||
// StorageHomeSutureService allows for the storage-home command to be embedded and supervised by a suture supervisor tree.
|
||||
type StorageHomeSutureService struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc // used to cancel the context go-micro services used to shutdown a service.
|
||||
cfg *config.Config
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewStorageHomeSutureService creates a new storage.StorageHomeSutureService
|
||||
func NewStorageHome(ctx context.Context, cfg *ociscfg.Config) suture.Service {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Storage.Reva.StorageHome.Context = sctx
|
||||
func NewStorageHome(cfg *ociscfg.Config) suture.Service {
|
||||
if cfg.Mode == 0 {
|
||||
cfg.Storage.Reva.StorageHome.Supervised = true
|
||||
}
|
||||
return StorageHomeSutureService{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg.Storage,
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
}
|
||||
|
||||
func (s StorageHomeSutureService) Serve() {
|
||||
func (s StorageHomeSutureService) Serve(ctx context.Context) error {
|
||||
s.cfg.Reva.StorageHome.Context = ctx
|
||||
f := &flag.FlagSet{}
|
||||
for k := range StorageHome(s.cfg).Flags {
|
||||
if err := StorageHome(s.cfg).Flags[k].Apply(f); err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
}
|
||||
ctx := cli.NewContext(nil, f, nil)
|
||||
cliCtx := cli.NewContext(nil, f, nil)
|
||||
if StorageHome(s.cfg).Before != nil {
|
||||
if err := StorageHome(s.cfg).Before(ctx); err != nil {
|
||||
return
|
||||
if err := StorageHome(s.cfg).Before(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := StorageHome(s.cfg).Action(ctx); err != nil {
|
||||
return
|
||||
if err := StorageHome(s.cfg).Action(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s StorageHomeSutureService) Stop() {
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -17,7 +17,7 @@ import (
|
||||
"github.com/owncloud/ocis/storage/pkg/flagset"
|
||||
"github.com/owncloud/ocis/storage/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/storage/pkg/service/external"
|
||||
"github.com/thejerf/suture"
|
||||
"github.com/thejerf/suture/v4"
|
||||
)
|
||||
|
||||
// StorageMetadata the entrypoint for the storage-storage-metadata command.
|
||||
@@ -204,43 +204,36 @@ func StorageMetadata(cfg *config.Config) *cli.Command {
|
||||
|
||||
// SutureService allows for the storage-metadata command to be embedded and supervised by a suture supervisor tree.
|
||||
type SutureService struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc // used to cancel the context go-micro services used to shutdown a service.
|
||||
cfg *config.Config
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewSutureService creates a new storagemetadata.SutureService
|
||||
func NewStorageMetadata(ctx context.Context, cfg *ociscfg.Config) suture.Service {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Storage.Reva.StorageMetadata.Context = sctx
|
||||
func NewStorageMetadata(cfg *ociscfg.Config) suture.Service {
|
||||
if cfg.Mode == 0 {
|
||||
cfg.Storage.Reva.StorageMetadata.Supervised = true
|
||||
}
|
||||
return SutureService{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg.Storage,
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
}
|
||||
|
||||
func (s SutureService) Serve() {
|
||||
func (s SutureService) Serve(ctx context.Context) error {
|
||||
s.cfg.Reva.StorageMetadata.Context = ctx
|
||||
f := &flag.FlagSet{}
|
||||
for k := range StorageMetadata(s.cfg).Flags {
|
||||
if err := StorageMetadata(s.cfg).Flags[k].Apply(f); err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
}
|
||||
ctx := cli.NewContext(nil, f, nil)
|
||||
cliCtx := cli.NewContext(nil, f, nil)
|
||||
if StorageMetadata(s.cfg).Before != nil {
|
||||
if err := StorageMetadata(s.cfg).Before(ctx); err != nil {
|
||||
return
|
||||
if err := StorageMetadata(s.cfg).Before(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := StorageMetadata(s.cfg).Action(ctx); err != nil {
|
||||
return
|
||||
if err := StorageMetadata(s.cfg).Action(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s SutureService) Stop() {
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/owncloud/ocis/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/storage/pkg/flagset"
|
||||
"github.com/owncloud/ocis/storage/pkg/server/debug"
|
||||
"github.com/thejerf/suture"
|
||||
"github.com/thejerf/suture/v4"
|
||||
)
|
||||
|
||||
// StoragePublicLink is the entrypoint for the reva-storage-public-link command.
|
||||
@@ -149,43 +149,36 @@ func StoragePublicLink(cfg *config.Config) *cli.Command {
|
||||
|
||||
// StoragePublicLinkSutureService allows for the storage-public-link command to be embedded and supervised by a suture supervisor tree.
|
||||
type StoragePublicLinkSutureService struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc // used to cancel the context go-micro services used to shutdown a service.
|
||||
cfg *config.Config
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewStoragePublicLinkSutureService creates a new storage.StoragePublicLinkSutureService
|
||||
func NewStoragePublicLink(ctx context.Context, cfg *ociscfg.Config) suture.Service {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Storage.Reva.StoragePublicLink.Context = sctx
|
||||
func NewStoragePublicLink(cfg *ociscfg.Config) suture.Service {
|
||||
if cfg.Mode == 0 {
|
||||
cfg.Storage.Reva.StoragePublicLink.Supervised = true
|
||||
}
|
||||
return StoragePublicLinkSutureService{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg.Storage,
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
}
|
||||
|
||||
func (s StoragePublicLinkSutureService) Serve() {
|
||||
func (s StoragePublicLinkSutureService) Serve(ctx context.Context) error {
|
||||
s.cfg.Reva.StoragePublicLink.Context = ctx
|
||||
f := &flag.FlagSet{}
|
||||
for k := range StoragePublicLink(s.cfg).Flags {
|
||||
if err := StoragePublicLink(s.cfg).Flags[k].Apply(f); err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
}
|
||||
ctx := cli.NewContext(nil, f, nil)
|
||||
cliCtx := cli.NewContext(nil, f, nil)
|
||||
if StoragePublicLink(s.cfg).Before != nil {
|
||||
if err := StoragePublicLink(s.cfg).Before(ctx); err != nil {
|
||||
return
|
||||
if err := StoragePublicLink(s.cfg).Before(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := StoragePublicLink(s.cfg).Action(ctx); err != nil {
|
||||
return
|
||||
if err := StoragePublicLink(s.cfg).Action(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s StoragePublicLinkSutureService) Stop() {
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ import (
|
||||
"github.com/owncloud/ocis/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/storage/pkg/flagset"
|
||||
"github.com/owncloud/ocis/storage/pkg/server/debug"
|
||||
"github.com/thejerf/suture"
|
||||
"github.com/thejerf/suture/v4"
|
||||
)
|
||||
|
||||
// StorageUsers is the entrypoint for the storage-users command.
|
||||
@@ -171,43 +171,36 @@ func StorageUsers(cfg *config.Config) *cli.Command {
|
||||
|
||||
// StorageUsersSutureService allows for the storage-home command to be embedded and supervised by a suture supervisor tree.
|
||||
type StorageUsersSutureService struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc // used to cancel the context go-micro services used to shutdown a service.
|
||||
cfg *config.Config
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewStorageUsersSutureService creates a new storage.StorageUsersSutureService
|
||||
func NewStorageUsers(ctx context.Context, cfg *ociscfg.Config) suture.Service {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Storage.Reva.StorageUsers.Context = sctx
|
||||
func NewStorageUsers(cfg *ociscfg.Config) suture.Service {
|
||||
if cfg.Mode == 0 {
|
||||
cfg.Storage.Reva.StorageUsers.Supervised = true
|
||||
}
|
||||
return StorageUsersSutureService{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg.Storage,
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
}
|
||||
|
||||
func (s StorageUsersSutureService) Serve() {
|
||||
func (s StorageUsersSutureService) Serve(ctx context.Context) error {
|
||||
s.cfg.Reva.StorageUsers.Context = ctx
|
||||
f := &flag.FlagSet{}
|
||||
for k := range StorageUsers(s.cfg).Flags {
|
||||
if err := StorageUsers(s.cfg).Flags[k].Apply(f); err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
}
|
||||
ctx := cli.NewContext(nil, f, nil)
|
||||
cliCtx := cli.NewContext(nil, f, nil)
|
||||
if StorageUsers(s.cfg).Before != nil {
|
||||
if err := StorageUsers(s.cfg).Before(ctx); err != nil {
|
||||
return
|
||||
if err := StorageUsers(s.cfg).Before(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := StorageUsers(s.cfg).Action(ctx); err != nil {
|
||||
return
|
||||
if err := StorageUsers(s.cfg).Action(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s StorageUsersSutureService) Stop() {
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -16,7 +16,7 @@ import (
|
||||
"github.com/owncloud/ocis/storage/pkg/config"
|
||||
"github.com/owncloud/ocis/storage/pkg/flagset"
|
||||
"github.com/owncloud/ocis/storage/pkg/server/debug"
|
||||
"github.com/thejerf/suture"
|
||||
"github.com/thejerf/suture/v4"
|
||||
)
|
||||
|
||||
// Users is the entrypoint for the sharing command.
|
||||
@@ -187,43 +187,36 @@ func Users(cfg *config.Config) *cli.Command {
|
||||
|
||||
// UsersProviderService allows for the storage-userprovider command to be embedded and supervised by a suture supervisor tree.
|
||||
type UsersProviderService struct {
|
||||
ctx context.Context
|
||||
cancel context.CancelFunc // used to cancel the context go-micro services used to shutdown a service.
|
||||
cfg *config.Config
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewUsersProviderService creates a new storage.UsersProviderService
|
||||
func NewUsersProviderService(ctx context.Context, cfg *ociscfg.Config) suture.Service {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Storage.Reva.Users.Context = sctx
|
||||
func NewUsersProviderService(cfg *ociscfg.Config) suture.Service {
|
||||
if cfg.Mode == 0 {
|
||||
cfg.Storage.Reva.Users.Supervised = true
|
||||
}
|
||||
return UsersProviderService{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg.Storage,
|
||||
cfg: cfg.Storage,
|
||||
}
|
||||
}
|
||||
|
||||
func (s UsersProviderService) Serve() {
|
||||
func (s UsersProviderService) Serve(ctx context.Context) error {
|
||||
s.cfg.Reva.Users.Context = ctx
|
||||
f := &flag.FlagSet{}
|
||||
for k := range Users(s.cfg).Flags {
|
||||
if err := Users(s.cfg).Flags[k].Apply(f); err != nil {
|
||||
return
|
||||
return err
|
||||
}
|
||||
}
|
||||
ctx := cli.NewContext(nil, f, nil)
|
||||
cliCtx := cli.NewContext(nil, f, nil)
|
||||
if Users(s.cfg).Before != nil {
|
||||
if err := Users(s.cfg).Before(ctx); err != nil {
|
||||
return
|
||||
if err := Users(s.cfg).Before(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
if err := Users(s.cfg).Action(ctx); err != nil {
|
||||
return
|
||||
if err := Users(s.cfg).Action(cliCtx); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
func (s UsersProviderService) Stop() {
|
||||
s.cancel()
|
||||
return nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user