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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user