mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 04:09:40 -06:00
add storage-groupsprovider
This commit is contained in:
@@ -2,6 +2,7 @@ package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"flag"
|
||||
"os"
|
||||
"os/signal"
|
||||
"path"
|
||||
@@ -204,3 +205,43 @@ 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
|
||||
}
|
||||
|
||||
// NewGroupsProvider creates a new storage.GroupsProvider
|
||||
func NewGroupsProvider(ctx context.Context, cfg *config.Config) GroupsProvider {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Context = sctx
|
||||
return GroupsProvider{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg,
|
||||
}
|
||||
}
|
||||
|
||||
func (s GroupsProvider) Serve() {
|
||||
f := &flag.FlagSet{}
|
||||
for k := range Groups(s.cfg).Flags {
|
||||
if err := Groups(s.cfg).Flags[k].Apply(f); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
ctx := 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).Action(ctx); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (s GroupsProvider) Stop() {
|
||||
s.cancel()
|
||||
}
|
||||
|
||||
@@ -214,7 +214,7 @@ type UsersProviderService struct {
|
||||
cfg *config.Config
|
||||
}
|
||||
|
||||
// NewUsersProviderService creates a new gateway.UsersProviderService
|
||||
// NewUsersProviderService creates a new storage.UsersProviderService
|
||||
func NewUsersProviderService(ctx context.Context, cfg *config.Config) UsersProviderService {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Context = sctx
|
||||
|
||||
Reference in New Issue
Block a user