mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2025-12-31 01:10:20 -06:00
add idp
This commit is contained in:
@@ -119,14 +119,14 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SutureService allows for the settings command to be embedded and supervised by a suture supervisor tree.
|
||||
// SutureService allows for the accounts 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 settings.SutureService
|
||||
// NewSutureService creates a new accounts.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.
|
||||
|
||||
@@ -11,20 +11,17 @@ func RootWithConfig(cfg *config.Config) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "log-level",
|
||||
Value: "info",
|
||||
Usage: "Set logging level",
|
||||
EnvVars: []string{"ACCOUNTS_LOG_LEVEL", "OCIS_LOG_LEVEL"},
|
||||
Destination: &cfg.Log.Level,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Value: true,
|
||||
Name: "log-pretty",
|
||||
Usage: "Enable pretty logging",
|
||||
EnvVars: []string{"ACCOUNTS_LOG_PRETTY", "OCIS_LOG_PRETTY"},
|
||||
Destination: &cfg.Log.Pretty,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Value: true,
|
||||
Name: "log-color",
|
||||
Usage: "Enable colored logging",
|
||||
EnvVars: []string{"ACCOUNTS_LOG_COLOR", "OCIS_LOG_COLOR"},
|
||||
|
||||
@@ -107,14 +107,14 @@ func ParseConfig(c *cli.Context, cfg *config.Config) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
// SutureService allows for the settings command to be embedded and supervised by a suture supervisor tree.
|
||||
// SutureService allows for the glauth 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 settings.SutureService
|
||||
// NewSutureService creates a new glauth.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.
|
||||
|
||||
@@ -4,10 +4,11 @@ import (
|
||||
"os"
|
||||
|
||||
"github.com/owncloud/ocis/idp/pkg/command"
|
||||
"github.com/owncloud/ocis/idp/pkg/config"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(); err != nil {
|
||||
if err := command.Execute(config.New()); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package config
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"stash.kopano.io/kc/konnect/bootstrap"
|
||||
)
|
||||
|
||||
@@ -75,6 +77,8 @@ type Config struct {
|
||||
IDP bootstrap.Config
|
||||
Ldap Ldap
|
||||
Service Service
|
||||
|
||||
Context context.Context
|
||||
}
|
||||
|
||||
// New initializes a new configuration with or without defaults.
|
||||
|
||||
@@ -10,23 +10,20 @@ func RootWithConfig(cfg *config.Config) []cli.Flag {
|
||||
return []cli.Flag{
|
||||
&cli.StringFlag{
|
||||
Name: "log-level",
|
||||
Value: "info",
|
||||
Usage: "Set logging level",
|
||||
EnvVars: []string{"IDP_LOG_LEVEL"},
|
||||
EnvVars: []string{"IDP_LOG_LEVEL", "OCIS_LOG_LEVEL"},
|
||||
Destination: &cfg.Log.Level,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Value: true,
|
||||
Name: "log-pretty",
|
||||
Usage: "Enable pretty logging",
|
||||
EnvVars: []string{"IDP_LOG_PRETTY"},
|
||||
EnvVars: []string{"IDP_LOG_PRETTY", "OCIS_LOG_PRETTY"},
|
||||
Destination: &cfg.Log.Pretty,
|
||||
},
|
||||
&cli.BoolFlag{
|
||||
Value: true,
|
||||
Name: "log-color",
|
||||
Usage: "Enable colored logging",
|
||||
EnvVars: []string{"IDP_LOG_COLOR"},
|
||||
EnvVars: []string{"IDP_LOG_COLOR", "OCIS_LOG_COLOR"},
|
||||
Destination: &cfg.Log.Color,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@ import (
|
||||
|
||||
accounts "github.com/owncloud/ocis/accounts/pkg/command"
|
||||
glauth "github.com/owncloud/ocis/glauth/pkg/command"
|
||||
idp "github.com/owncloud/ocis/idp/pkg/command"
|
||||
settings "github.com/owncloud/ocis/settings/pkg/command"
|
||||
|
||||
"github.com/thejerf/suture"
|
||||
@@ -33,7 +34,7 @@ var (
|
||||
|
||||
// Extensions are oCIS extension services
|
||||
Extensions = []string{
|
||||
"glauth",
|
||||
"glauth", // done
|
||||
"idp",
|
||||
"ocs",
|
||||
"onlyoffice",
|
||||
@@ -102,6 +103,7 @@ func (r *Runtime) Start() error {
|
||||
// - replace occurrences of log.Fatal in favor of panic() since the supervisor relies on panics.
|
||||
// - the runtime should ideally run as an rpc service one can do requests, like the good ol' pman, rest in pieces.
|
||||
// - establish on suture a max number of retries before all initialization comes to a halt.
|
||||
// - remove default log flagset values.
|
||||
|
||||
// propagate reva log config to storage services
|
||||
r.c.Storage.Log.Level = r.c.Log.Level
|
||||
@@ -112,6 +114,7 @@ func (r *Runtime) Start() error {
|
||||
addServiceToken("storagemetadata", supervisor.Add(storage.NewStorageMetadata(globalCtx, r.c.Storage)))
|
||||
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)))
|
||||
|
||||
// TODO(refs) debug line with supervised services.
|
||||
go supervisor.ServeBackground()
|
||||
|
||||
Reference in New Issue
Block a user