Files
opencloud/ocis/pkg/command/glauth.go
2021-03-12 14:13:06 +01:00

49 lines
1.3 KiB
Go

package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/glauth/pkg/command"
svcconfig "github.com/owncloud/ocis/glauth/pkg/config"
"github.com/owncloud/ocis/glauth/pkg/flagset"
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/ocis/pkg/version"
)
// GLAuthCommand is the entrypoint for the glauth command.
func GLAuthCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "glauth",
Usage: "Start glauth server",
Category: "Extensions",
Flags: flagset.ServerWithConfig(cfg.GLAuth),
Before: func(ctx *cli.Context) error {
return ParseConfig(ctx, cfg)
},
Action: func(c *cli.Context) error {
origCmd := command.Server(configureGLAuth(cfg))
return handleOriginalAction(c, origCmd)
},
}
}
func configureGLAuth(cfg *config.Config) *svcconfig.Config {
cfg.GLAuth.Log.Level = cfg.Log.Level
cfg.GLAuth.Log.Pretty = cfg.Log.Pretty
cfg.GLAuth.Log.Color = cfg.Log.Color
cfg.GLAuth.Version = version.String
if cfg.Tracing.Enabled {
cfg.GLAuth.Tracing.Enabled = cfg.Tracing.Enabled
cfg.GLAuth.Tracing.Type = cfg.Tracing.Type
cfg.GLAuth.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.GLAuth.Tracing.Collector = cfg.Tracing.Collector
}
return cfg.GLAuth
}
func init() {
register.AddCommand(GLAuthCommand)
}