mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 04:09:40 -06:00
add idp
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
@@ -13,9 +14,7 @@ import (
|
||||
)
|
||||
|
||||
// Execute is the entry point for the ocis-idp command.
|
||||
func Execute() error {
|
||||
cfg := config.New()
|
||||
|
||||
func Execute(cfg *config.Config) error {
|
||||
app := &cli.App{
|
||||
Name: "ocis-idp",
|
||||
Version: version.String,
|
||||
@@ -108,3 +107,31 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// SutureService allows for the idp 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
|
||||
}
|
||||
|
||||
// NewSutureService creates a new idp.SutureService
|
||||
func NewSutureService(ctx context.Context, cfg *config.Config) SutureService {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Context = sctx // propagate the context down to the go-micro services.
|
||||
return SutureService{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
cfg: cfg,
|
||||
}
|
||||
}
|
||||
|
||||
func (s SutureService) Serve() {
|
||||
if err := Execute(s.cfg); err != nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (s SutureService) Stop() {
|
||||
s.cancel()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user