add ocis subcommand

This commit is contained in:
A.Unger
2020-09-18 13:15:21 +02:00
parent 45f8b7c403
commit 1517eb9436
170 changed files with 13980 additions and 0 deletions
+49
View File
@@ -0,0 +1,49 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/accounts/pkg/command"
svcconfig "github.com/owncloud/ocis/accounts/pkg/config"
"github.com/owncloud/ocis/accounts/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// AccountsCommand is the entrypoint for the accounts command.
func AccountsCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "accounts",
Usage: "Start accounts server",
Category: "Extensions",
Flags: flagset.ServerWithConfig(cfg.Accounts),
Subcommands: []*cli.Command{
command.ListAccounts(cfg.Accounts),
command.AddAccount(cfg.Accounts),
command.UpdateAccount(cfg.Accounts),
command.RemoveAccount(cfg.Accounts),
command.InspectAccount(cfg.Accounts),
},
Action: func(c *cli.Context) error {
accountsCommand := command.Server(configureAccounts(cfg))
if err := accountsCommand.Before(c); err != nil {
return err
}
return cli.HandleAction(accountsCommand.Action, c)
},
}
}
func configureAccounts(cfg *config.Config) *svcconfig.Config {
cfg.Accounts.Log.Level = cfg.Log.Level
cfg.Accounts.Log.Pretty = cfg.Log.Pretty
cfg.Accounts.Log.Color = cfg.Log.Color
return cfg.Accounts
}
func init() {
register.AddCommand(AccountsCommand)
}
+48
View File
@@ -0,0 +1,48 @@
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"
)
// 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),
Action: func(c *cli.Context) error {
scfg := configureGLAuth(cfg)
return cli.HandleAction(
command.Server(scfg).Action,
c,
)
},
}
}
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
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
cfg.GLAuth.Tracing.Service = cfg.Tracing.Service
}
return cfg.GLAuth
}
func init() {
register.AddCommand(GLAuthCommand)
}
+54
View File
@@ -0,0 +1,54 @@
package command
import (
"fmt"
"net/http"
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// Health is the entrypoint for the health command.
func Health(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "health",
Usage: "Check health status",
Flags: flagset.HealthWithConfig(cfg),
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
resp, err := http.Get(
fmt.Sprintf(
"http://%s/healthz",
cfg.Debug.Addr,
),
)
if err != nil {
logger.Fatal().
Err(err).
Msg("Failed to request health check")
}
defer resp.Body.Close()
if resp.StatusCode != http.StatusOK {
logger.Fatal().
Int("code", resp.StatusCode).
Msg("Health seems to be in bad state")
}
logger.Debug().
Int("code", resp.StatusCode).
Msg("Health got a good state")
return nil
},
}
}
func init() {
register.AddCommand(Health)
}
+55
View File
@@ -0,0 +1,55 @@
package command
import (
"fmt"
"log"
"net"
"net/rpc"
"os"
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// KillCommand is the entrypoint for the kill command.
func KillCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "kill",
Usage: "Kill an extension by name",
Category: "Runtime",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "hostname",
Value: "localhost",
EnvVars: []string{"OCIS_RUNTIME_HOSTNAME"},
Destination: &cfg.Runtime.Hostname,
},
&cli.StringFlag{
Name: "port",
Value: "10666",
EnvVars: []string{"OCIS_RUNTIME_PORT"},
Destination: &cfg.Runtime.Port,
},
},
Action: func(c *cli.Context) error {
client, err := rpc.DialHTTP("tcp", net.JoinHostPort(cfg.Runtime.Hostname, cfg.Runtime.Port))
if err != nil {
log.Fatal("dialing:", err)
}
var arg1 int
if err := client.Call("Service.Kill", os.Args[2], &arg1); err != nil {
log.Fatal(err)
}
fmt.Printf("process %v terminated", os.Args[2])
return nil
},
}
}
func init() {
register.AddCommand(KillCommand)
}
+50
View File
@@ -0,0 +1,50 @@
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/konnectd/pkg/command"
svcconfig "github.com/owncloud/ocis/konnectd/pkg/config"
"github.com/owncloud/ocis/konnectd/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// KonnectdCommand is the entrypoint for the konnectd command.
func KonnectdCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "konnectd",
Usage: "Start konnectd server",
Category: "Extensions",
Flags: flagset.ServerWithConfig(cfg.Konnectd),
Action: func(c *cli.Context) error {
konnectdCommand := command.Server(configureKonnectd(cfg))
if err := konnectdCommand.Before(c); err != nil {
return err
}
return cli.HandleAction(konnectdCommand.Action, c)
},
}
}
func configureKonnectd(cfg *config.Config) *svcconfig.Config {
cfg.Konnectd.Log.Level = cfg.Log.Level
cfg.Konnectd.Log.Pretty = cfg.Log.Pretty
cfg.Konnectd.Log.Color = cfg.Log.Color
cfg.Konnectd.HTTP.TLS = false
if cfg.Tracing.Enabled {
cfg.Konnectd.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Konnectd.Tracing.Type = cfg.Tracing.Type
cfg.Konnectd.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Konnectd.Tracing.Collector = cfg.Tracing.Collector
cfg.Konnectd.Tracing.Service = cfg.Tracing.Service
}
return cfg.Konnectd
}
func init() {
register.AddCommand(KonnectdCommand)
}
+55
View File
@@ -0,0 +1,55 @@
package command
import (
"fmt"
"log"
"net"
"net/rpc"
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// ListCommand is the entrypoint for the list command.
func ListCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "list",
Usage: "Lists running ocis extensions",
Category: "Runtime",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "hostname",
Value: "localhost",
EnvVars: []string{"OCIS_RUNTIME_HOSTNAME"},
Destination: &cfg.Runtime.Hostname,
},
&cli.StringFlag{
Name: "port",
Value: "10666",
EnvVars: []string{"OCIS_RUNTIME_PORT"},
Destination: &cfg.Runtime.Port,
},
},
Action: func(c *cli.Context) error {
client, err := rpc.DialHTTP("tcp", net.JoinHostPort(cfg.Runtime.Hostname, cfg.Runtime.Port))
if err != nil {
log.Fatal("dialing:", err)
}
var arg1 string
if err := client.Call("Service.List", struct{}{}, &arg1); err != nil {
log.Fatal(err)
}
fmt.Println(arg1)
return nil
},
}
}
func init() {
register.AddCommand(ListCommand)
}
+52
View File
@@ -0,0 +1,52 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocs/pkg/command"
svcconfig "github.com/owncloud/ocis/ocs/pkg/config"
"github.com/owncloud/ocis/ocs/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// OCSCommand is the entrypoint for the ocs command.
func OCSCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "ocs",
Usage: "Start ocs server",
Category: "Extensions",
Flags: flagset.ServerWithConfig(cfg.OCS),
Action: func(ctx *cli.Context) error {
ocsCommand := command.Server(configureOCS(cfg))
if err := ocsCommand.Before(ctx); err != nil {
return err
}
return cli.HandleAction(ocsCommand.Action, ctx)
},
}
}
func configureOCS(cfg *config.Config) *svcconfig.Config {
cfg.OCS.Log.Level = cfg.Log.Level
cfg.OCS.Log.Pretty = cfg.Log.Pretty
cfg.OCS.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.OCS.Tracing.Enabled = cfg.Tracing.Enabled
cfg.OCS.Tracing.Type = cfg.Tracing.Type
cfg.OCS.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.OCS.Tracing.Collector = cfg.Tracing.Collector
cfg.OCS.Tracing.Service = cfg.Tracing.Service
}
return cfg.OCS
}
func init() {
register.AddCommand(OCSCommand)
}
+58
View File
@@ -0,0 +1,58 @@
package command
import (
"strings"
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-phoenix/pkg/command"
"github.com/owncloud/ocis/ocis-phoenix/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// PhoenixCommand is the entrypoint for the phoenix command.
func PhoenixCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "phoenix",
Usage: "Start phoenix server",
Category: "Extensions",
Flags: flagset.ServerWithConfig(cfg.Phoenix),
Before: func(c *cli.Context) error {
if cfg.HTTP.Root != "/" {
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
}
cfg.Phoenix.Phoenix.Config.Apps = c.StringSlice("web-config-app")
return nil
},
Action: func(c *cli.Context) error {
phoenixCommand := command.Server(configurePhoenix(cfg).Phoenix)
if err := phoenixCommand.Before(c); err != nil {
return err
}
return cli.HandleAction(phoenixCommand.Action, c)
},
}
}
func configurePhoenix(cfg *config.Config) *config.Config {
cfg.Phoenix.Log.Level = cfg.Log.Level
cfg.Phoenix.Log.Pretty = cfg.Log.Pretty
cfg.Phoenix.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Phoenix.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Phoenix.Tracing.Type = cfg.Tracing.Type
cfg.Phoenix.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Phoenix.Tracing.Collector = cfg.Tracing.Collector
cfg.Phoenix.Tracing.Service = cfg.Tracing.Service
}
return cfg
}
func init() {
register.AddCommand(PhoenixCommand)
}
+55
View File
@@ -0,0 +1,55 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/proxy/pkg/command"
svcconfig "github.com/owncloud/ocis/proxy/pkg/config"
"github.com/owncloud/ocis/proxy/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// ProxyCommand is the entry point for the proxy command.
func ProxyCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "proxy",
Usage: "Start proxy server",
Category: "Extensions",
Flags: flagset.ServerWithConfig(cfg.Proxy),
Action: func(ctx *cli.Context) error {
proxyCommand := command.Server(configureProxy(cfg))
if err := proxyCommand.Before(ctx); err != nil {
return err
}
return cli.HandleAction(proxyCommand.Action, ctx)
},
}
}
func configureProxy(cfg *config.Config) *svcconfig.Config {
cfg.Proxy.Log.Level = cfg.Log.Level
cfg.Proxy.Log.Pretty = cfg.Log.Pretty
cfg.Proxy.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Proxy.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Proxy.Tracing.Type = cfg.Tracing.Type
cfg.Proxy.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Proxy.Tracing.Collector = cfg.Tracing.Collector
cfg.Proxy.Tracing.Service = cfg.Tracing.Service
}
if cfg.Reva.Reva.JWTSecret != "" {
cfg.Proxy.TokenManager.JWTSecret = cfg.Reva.Reva.JWTSecret
}
return cfg.Proxy
}
func init() {
register.AddCommand(ProxyCommand)
}
+50
View File
@@ -0,0 +1,50 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/command"
svcconfig "github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// RevaAuthBasicCommand is the entrypoint for the reva-auth-basic command.
func RevaAuthBasicCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-auth-basic",
Usage: "Start reva auth-basic service",
Category: "Extensions",
Flags: flagset.AuthBasicWithConfig(cfg.Reva),
Action: func(c *cli.Context) error {
scfg := configureRevaAuthBasic(cfg)
return cli.HandleAction(
command.AuthBasic(scfg).Action,
c,
)
},
}
}
func configureRevaAuthBasic(cfg *config.Config) *svcconfig.Config {
cfg.Reva.Log.Level = cfg.Log.Level
cfg.Reva.Log.Pretty = cfg.Log.Pretty
cfg.Reva.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Reva.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Reva.Tracing.Type = cfg.Tracing.Type
cfg.Reva.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Reva.Tracing.Collector = cfg.Tracing.Collector
cfg.Reva.Tracing.Service = cfg.Tracing.Service
}
return cfg.Reva
}
func init() {
register.AddCommand(RevaAuthBasicCommand)
}
+50
View File
@@ -0,0 +1,50 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/command"
svcconfig "github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// RevaAuthBearerCommand is the entrypoint for the reva-auth-bearer command.
func RevaAuthBearerCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-auth-bearer",
Usage: "Start reva auth-bearer service",
Category: "Extensions",
Flags: flagset.AuthBearerWithConfig(cfg.Reva),
Action: func(c *cli.Context) error {
scfg := configureRevaAuthBearer(cfg)
return cli.HandleAction(
command.AuthBearer(scfg).Action,
c,
)
},
}
}
func configureRevaAuthBearer(cfg *config.Config) *svcconfig.Config {
cfg.Reva.Log.Level = cfg.Log.Level
cfg.Reva.Log.Pretty = cfg.Log.Pretty
cfg.Reva.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Reva.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Reva.Tracing.Type = cfg.Tracing.Type
cfg.Reva.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Reva.Tracing.Collector = cfg.Tracing.Collector
cfg.Reva.Tracing.Service = cfg.Tracing.Service
}
return cfg.Reva
}
func init() {
register.AddCommand(RevaAuthBearerCommand)
}
+50
View File
@@ -0,0 +1,50 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/command"
svcconfig "github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// RevaFrontendCommand is the entrypoint for the reva-frontend command.
func RevaFrontendCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-frontend",
Usage: "Start reva frontend",
Category: "Extensions",
Flags: flagset.FrontendWithConfig(cfg.Reva),
Action: func(c *cli.Context) error {
scfg := configureRevaFrontend(cfg)
return cli.HandleAction(
command.Frontend(scfg).Action,
c,
)
},
}
}
func configureRevaFrontend(cfg *config.Config) *svcconfig.Config {
cfg.Reva.Log.Level = cfg.Log.Level
cfg.Reva.Log.Pretty = cfg.Log.Pretty
cfg.Reva.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Reva.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Reva.Tracing.Type = cfg.Tracing.Type
cfg.Reva.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Reva.Tracing.Collector = cfg.Tracing.Collector
cfg.Reva.Tracing.Service = cfg.Tracing.Service
}
return cfg.Reva
}
func init() {
register.AddCommand(RevaFrontendCommand)
}
+50
View File
@@ -0,0 +1,50 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/command"
svcconfig "github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// RevaGatewayCommand is the entrypoint for the reva-gateway command.
func RevaGatewayCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-gateway",
Usage: "Start reva gateway",
Category: "Extensions",
Flags: flagset.GatewayWithConfig(cfg.Reva),
Action: func(c *cli.Context) error {
scfg := configureRevaGateway(cfg)
return cli.HandleAction(
command.Gateway(scfg).Action,
c,
)
},
}
}
func configureRevaGateway(cfg *config.Config) *svcconfig.Config {
cfg.Reva.Log.Level = cfg.Log.Level
cfg.Reva.Log.Pretty = cfg.Log.Pretty
cfg.Reva.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Reva.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Reva.Tracing.Type = cfg.Tracing.Type
cfg.Reva.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Reva.Tracing.Collector = cfg.Tracing.Collector
cfg.Reva.Tracing.Service = cfg.Tracing.Service
}
return cfg.Reva
}
func init() {
register.AddCommand(RevaGatewayCommand)
}
+50
View File
@@ -0,0 +1,50 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/command"
svcconfig "github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// RevaSharingCommand is the entrypoint for the reva-sharing command.
func RevaSharingCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-sharing",
Usage: "Start reva sharing service",
Category: "Extensions",
Flags: flagset.SharingWithConfig(cfg.Reva),
Action: func(c *cli.Context) error {
scfg := configureRevaSharing(cfg)
return cli.HandleAction(
command.Sharing(scfg).Action,
c,
)
},
}
}
func configureRevaSharing(cfg *config.Config) *svcconfig.Config {
cfg.Reva.Log.Level = cfg.Log.Level
cfg.Reva.Log.Pretty = cfg.Log.Pretty
cfg.Reva.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Reva.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Reva.Tracing.Type = cfg.Tracing.Type
cfg.Reva.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Reva.Tracing.Collector = cfg.Tracing.Collector
cfg.Reva.Tracing.Service = cfg.Tracing.Service
}
return cfg.Reva
}
func init() {
register.AddCommand(RevaSharingCommand)
}
+50
View File
@@ -0,0 +1,50 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/command"
svcconfig "github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// RevaStorageEOSCommand is the entrypoint for the reva-storage-oc command.
func RevaStorageEOSCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-storage-eos",
Usage: "Start reva storage service for eos mount",
Category: "Extensions",
Flags: flagset.StorageEOSWithConfig(cfg.Reva),
Action: func(c *cli.Context) error {
scfg := configureRevaStorageEOS(cfg)
return cli.HandleAction(
command.StorageEOS(scfg).Action,
c,
)
},
}
}
func configureRevaStorageEOS(cfg *config.Config) *svcconfig.Config {
cfg.Reva.Log.Level = cfg.Log.Level
cfg.Reva.Log.Pretty = cfg.Log.Pretty
cfg.Reva.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Reva.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Reva.Tracing.Type = cfg.Tracing.Type
cfg.Reva.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Reva.Tracing.Collector = cfg.Tracing.Collector
cfg.Reva.Tracing.Service = cfg.Tracing.Service
}
return cfg.Reva
}
func init() {
register.AddCommand(RevaStorageEOSCommand)
}
+50
View File
@@ -0,0 +1,50 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/command"
svcconfig "github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// RevaStorageEOSDataCommand is the entrypoint for the reva-storage-eos-data command.
func RevaStorageEOSDataCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-storage-eos-data",
Usage: "Start reva storage data provider for eos mount",
Category: "Extensions",
Flags: flagset.StorageEOSDataWithConfig(cfg.Reva),
Action: func(c *cli.Context) error {
scfg := configureRevaStorageEOSData(cfg)
return cli.HandleAction(
command.StorageEOSData(scfg).Action,
c,
)
},
}
}
func configureRevaStorageEOSData(cfg *config.Config) *svcconfig.Config {
cfg.Reva.Log.Level = cfg.Log.Level
cfg.Reva.Log.Pretty = cfg.Log.Pretty
cfg.Reva.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Reva.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Reva.Tracing.Type = cfg.Tracing.Type
cfg.Reva.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Reva.Tracing.Collector = cfg.Tracing.Collector
cfg.Reva.Tracing.Service = cfg.Tracing.Service
}
return cfg.Reva
}
func init() {
register.AddCommand(RevaStorageEOSDataCommand)
}
+50
View File
@@ -0,0 +1,50 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/command"
svcconfig "github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// RevaStorageHomeCommand is the entrypoint for the reva-storage-home command.
func RevaStorageHomeCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-storage-home",
Usage: "Start reva storage service for home mount",
Category: "Extensions",
Flags: flagset.StorageHomeWithConfig(cfg.Reva),
Action: func(c *cli.Context) error {
scfg := configureRevaStorageHome(cfg)
return cli.HandleAction(
command.StorageHome(scfg).Action,
c,
)
},
}
}
func configureRevaStorageHome(cfg *config.Config) *svcconfig.Config {
cfg.Reva.Log.Level = cfg.Log.Level
cfg.Reva.Log.Pretty = cfg.Log.Pretty
cfg.Reva.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Reva.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Reva.Tracing.Type = cfg.Tracing.Type
cfg.Reva.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Reva.Tracing.Collector = cfg.Tracing.Collector
cfg.Reva.Tracing.Service = cfg.Tracing.Service
}
return cfg.Reva
}
func init() {
register.AddCommand(RevaStorageHomeCommand)
}
+50
View File
@@ -0,0 +1,50 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/command"
svcconfig "github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// RevaStorageHomeDataCommand is the entrypoint for the reva-storage-home-data command.
func RevaStorageHomeDataCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-storage-home-data",
Usage: "Start reva storage data provider for home mount",
Category: "Extensions",
Flags: flagset.StorageHomeDataWithConfig(cfg.Reva),
Action: func(c *cli.Context) error {
scfg := configureRevaStorageHomeData(cfg)
return cli.HandleAction(
command.StorageHomeData(scfg).Action,
c,
)
},
}
}
func configureRevaStorageHomeData(cfg *config.Config) *svcconfig.Config {
cfg.Reva.Log.Level = cfg.Log.Level
cfg.Reva.Log.Pretty = cfg.Log.Pretty
cfg.Reva.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Reva.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Reva.Tracing.Type = cfg.Tracing.Type
cfg.Reva.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Reva.Tracing.Collector = cfg.Tracing.Collector
cfg.Reva.Tracing.Service = cfg.Tracing.Service
}
return cfg.Reva
}
func init() {
register.AddCommand(RevaStorageHomeDataCommand)
}
+50
View File
@@ -0,0 +1,50 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/command"
svcconfig "github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// RevaStorageOCCommand is the entrypoint for the reva-storage-oc command.
func RevaStorageOCCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-storage-oc",
Usage: "Start reva storage service for oc mount",
Category: "Extensions",
Flags: flagset.StorageOCWithConfig(cfg.Reva),
Action: func(c *cli.Context) error {
scfg := configureRevaStorageOC(cfg)
return cli.HandleAction(
command.StorageOC(scfg).Action,
c,
)
},
}
}
func configureRevaStorageOC(cfg *config.Config) *svcconfig.Config {
cfg.Reva.Log.Level = cfg.Log.Level
cfg.Reva.Log.Pretty = cfg.Log.Pretty
cfg.Reva.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Reva.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Reva.Tracing.Type = cfg.Tracing.Type
cfg.Reva.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Reva.Tracing.Collector = cfg.Tracing.Collector
cfg.Reva.Tracing.Service = cfg.Tracing.Service
}
return cfg.Reva
}
func init() {
register.AddCommand(RevaStorageOCCommand)
}
+50
View File
@@ -0,0 +1,50 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/command"
svcconfig "github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// RevaStorageOCDataCommand is the entrypoint for the reva-storage-oc-data command.
func RevaStorageOCDataCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-storage-oc-data",
Usage: "Start reva storage data provider for oc mount",
Category: "Extensions",
Flags: flagset.StorageOCDataWithConfig(cfg.Reva),
Action: func(c *cli.Context) error {
scfg := configureRevaStorageOCData(cfg)
return cli.HandleAction(
command.StorageOCData(scfg).Action,
c,
)
},
}
}
func configureRevaStorageOCData(cfg *config.Config) *svcconfig.Config {
cfg.Reva.Log.Level = cfg.Log.Level
cfg.Reva.Log.Pretty = cfg.Log.Pretty
cfg.Reva.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Reva.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Reva.Tracing.Type = cfg.Tracing.Type
cfg.Reva.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Reva.Tracing.Collector = cfg.Tracing.Collector
cfg.Reva.Tracing.Service = cfg.Tracing.Service
}
return cfg.Reva
}
func init() {
register.AddCommand(RevaStorageOCDataCommand)
}
+50
View File
@@ -0,0 +1,50 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/command"
svcconfig "github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// RevaStoragePublicLinkCommand is the entrypoint for the reva-storage-oc command.
func RevaStoragePublicLinkCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-storage-public-link",
Usage: "Start reva public link storage",
Category: "Extensions",
Flags: flagset.StoragePublicLink(cfg.Reva),
Action: func(c *cli.Context) error {
scfg := configureRevaStoragePublicLink(cfg)
return cli.HandleAction(
command.StoragePublicLink(scfg).Action,
c,
)
},
}
}
func configureRevaStoragePublicLink(cfg *config.Config) *svcconfig.Config {
cfg.Reva.Log.Level = cfg.Log.Level
cfg.Reva.Log.Pretty = cfg.Log.Pretty
cfg.Reva.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Reva.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Reva.Tracing.Type = cfg.Tracing.Type
cfg.Reva.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Reva.Tracing.Collector = cfg.Tracing.Collector
cfg.Reva.Tracing.Service = cfg.Tracing.Service
}
return cfg.Reva
}
func init() {
register.AddCommand(RevaStoragePublicLinkCommand)
}
+50
View File
@@ -0,0 +1,50 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/command"
svcconfig "github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// RevaStorageRootCommand is the entrypoint for the reva-storage-root command.
func RevaStorageRootCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-storage-root",
Usage: "Start reva root storage",
Category: "Extensions",
Flags: flagset.StorageRootWithConfig(cfg.Reva),
Action: func(c *cli.Context) error {
scfg := configureRevaStorageRoot(cfg)
return cli.HandleAction(
command.StorageRoot(scfg).Action,
c,
)
},
}
}
func configureRevaStorageRoot(cfg *config.Config) *svcconfig.Config {
cfg.Reva.Log.Level = cfg.Log.Level
cfg.Reva.Log.Pretty = cfg.Log.Pretty
cfg.Reva.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Reva.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Reva.Tracing.Type = cfg.Tracing.Type
cfg.Reva.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Reva.Tracing.Collector = cfg.Tracing.Collector
cfg.Reva.Tracing.Service = cfg.Tracing.Service
}
return cfg.Reva
}
func init() {
register.AddCommand(RevaStorageRootCommand)
}
+50
View File
@@ -0,0 +1,50 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-reva/pkg/command"
svcconfig "github.com/owncloud/ocis/ocis-reva/pkg/config"
"github.com/owncloud/ocis/ocis-reva/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// RevaUsersCommand is the entrypoint for the reva-users command.
func RevaUsersCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "reva-users",
Usage: "Start reva users service",
Category: "Extensions",
Flags: flagset.UsersWithConfig(cfg.Reva),
Action: func(c *cli.Context) error {
scfg := configureRevaUsers(cfg)
return cli.HandleAction(
command.Users(scfg).Action,
c,
)
},
}
}
func configureRevaUsers(cfg *config.Config) *svcconfig.Config {
cfg.Reva.Log.Level = cfg.Log.Level
cfg.Reva.Log.Pretty = cfg.Log.Pretty
cfg.Reva.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Reva.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Reva.Tracing.Type = cfg.Tracing.Type
cfg.Reva.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Reva.Tracing.Collector = cfg.Tracing.Collector
cfg.Reva.Tracing.Service = cfg.Tracing.Service
}
return cfg.Reva
}
func init() {
register.AddCommand(RevaUsersCommand)
}
+64
View File
@@ -0,0 +1,64 @@
package command
import (
"os"
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/ocis/pkg/runtime"
"github.com/owncloud/ocis/ocis/pkg/version"
)
// Execute is the entry point for the ocis-ocis command.
func Execute() error {
cfg := config.New()
app := &cli.App{
Name: "ocis",
Version: version.String,
Usage: "ownCloud Infinite Scale Stack",
Compiled: version.Compiled(),
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
Flags: flagset.RootWithConfig(cfg),
}
for _, fn := range register.Commands {
app.Commands = append(
app.Commands,
fn(cfg),
)
}
runtime.AddMicroPlatform(app)
cli.HelpFlag = &cli.BoolFlag{
Name: "help,h",
Usage: "Show the help",
}
cli.VersionFlag = &cli.BoolFlag{
Name: "version,v",
Usage: "Print the version",
}
return app.Run(os.Args)
}
// NewLogger initializes a service-specific logger instance
func NewLogger(cfg *config.Config) log.Logger {
return log.NewLogger(
log.Name("ocis"),
log.Level(cfg.Log.Level),
log.Pretty(cfg.Log.Pretty),
log.Color(cfg.Log.Color),
)
}
+58
View File
@@ -0,0 +1,58 @@
package command
import (
"fmt"
"log"
"net"
"net/rpc"
"os"
cli "github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/refs/pman/pkg/process"
)
// RunCommand is the entrypoint for the run command.
func RunCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "run",
Usage: "Runs an extension",
Category: "Runtime",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "hostname",
Value: "localhost",
EnvVars: []string{"OCIS_RUNTIME_HOSTNAME"},
Destination: &cfg.Runtime.Hostname,
},
&cli.StringFlag{
Name: "port",
Value: "10666",
EnvVars: []string{"OCIS_RUNTIME_PORT"},
Destination: &cfg.Runtime.Port,
},
},
Action: func(c *cli.Context) error {
client, err := rpc.DialHTTP("tcp", net.JoinHostPort(cfg.Runtime.Hostname, cfg.Runtime.Port))
if err != nil {
log.Fatal("dialing:", err)
}
proc := process.NewProcEntry(os.Args[2], os.Environ(), []string{os.Args[2]}...)
var res int
if err := client.Call("Service.Start", proc, &res); err != nil {
log.Fatal(err)
}
fmt.Println(res)
return nil
},
}
}
func init() {
register.AddCommand(RunCommand)
}
+67
View File
@@ -0,0 +1,67 @@
// +build !simple
package command
import (
"strings"
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/owncloud/ocis/ocis/pkg/runtime"
"github.com/owncloud/ocis/ocis/pkg/tracing"
)
// Server is the entrypoint for the server command.
func Server(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "server",
Usage: "Start fullstack server",
Category: "Fullstack",
Flags: flagset.ServerWithConfig(cfg),
Before: func(c *cli.Context) error {
if cfg.HTTP.Root != "/" {
cfg.HTTP.Root = strings.TrimSuffix(cfg.HTTP.Root, "/")
}
return nil
},
Action: func(c *cli.Context) error {
if err := tracing.Start(cfg); err != nil {
return err
}
r := runtime.New()
// TODO temporary service startup selection. Should go away and the runtime should take care of it.
return r.Start(append([]string{
"accounts",
"settings",
"konnectd",
"proxy",
"ocs",
"phoenix",
"glauth",
"webdav",
"store",
"thumbnails",
"reva-frontend",
"reva-gateway",
"reva-users",
"reva-auth-basic",
"reva-auth-bearer",
"reva-storage-home",
"reva-storage-home-data",
"reva-storage-eos",
"reva-storage-eos-data",
"reva-storage-oc",
"reva-storage-oc-data",
"reva-storage-public-link",
}, runtime.MicroServices...)...)
},
}
}
func init() {
register.AddCommand(Server)
}
+55
View File
@@ -0,0 +1,55 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/settings/pkg/command"
svcconfig "github.com/owncloud/ocis/settings/pkg/config"
"github.com/owncloud/ocis/settings/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// SettingsCommand is the entry point for the settings command.
func SettingsCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "settings",
Usage: "Start settings server",
Category: "Extensions",
Flags: flagset.ServerWithConfig(cfg.Settings),
Action: func(ctx *cli.Context) error {
settingsCommand := command.Server(configureSettings(cfg))
if err := settingsCommand.Before(ctx); err != nil {
return err
}
return cli.HandleAction(settingsCommand.Action, ctx)
},
}
}
func configureSettings(cfg *config.Config) *svcconfig.Config {
cfg.Settings.Log.Level = cfg.Log.Level
cfg.Settings.Log.Pretty = cfg.Log.Pretty
cfg.Settings.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Settings.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Settings.Tracing.Type = cfg.Tracing.Type
cfg.Settings.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Settings.Tracing.Collector = cfg.Tracing.Collector
cfg.Settings.Tracing.Service = cfg.Tracing.Service
}
if cfg.Reva.Reva.JWTSecret != "" {
cfg.Settings.TokenManager.JWTSecret = cfg.Reva.Reva.JWTSecret
}
return cfg.Settings
}
func init() {
register.AddCommand(SettingsCommand)
}
+51
View File
@@ -0,0 +1,51 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/store/pkg/command"
svcconfig "github.com/owncloud/ocis/store/pkg/config"
"github.com/owncloud/ocis/store/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// StoreCommand is the entrypoint for the ocs command.
func StoreCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "store",
Usage: "Start a go-micro store",
Category: "Extensions",
Flags: flagset.ServerWithConfig(cfg.Store),
Action: func(ctx *cli.Context) error {
storeCommand := command.Server(configureStore(cfg))
if err := storeCommand.Before(ctx); err != nil {
return err
}
return cli.HandleAction(storeCommand.Action, ctx)
},
}
}
func configureStore(cfg *config.Config) *svcconfig.Config {
cfg.Store.Log.Level = cfg.Log.Level
cfg.Store.Log.Pretty = cfg.Log.Pretty
cfg.Store.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Store.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Store.Tracing.Type = cfg.Tracing.Type
cfg.Store.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Store.Tracing.Collector = cfg.Tracing.Collector
cfg.Store.Tracing.Service = cfg.Tracing.Service
}
return cfg.Store
}
func init() {
register.AddCommand(StoreCommand)
}
+52
View File
@@ -0,0 +1,52 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/thumbnails/pkg/command"
"github.com/owncloud/ocis/thumbnails/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
svcconfig "github.com/owncloud/ocis/thumbnails/pkg/config"
)
// ThumbnailsCommand is the entrypoint for the thumbnails command.
func ThumbnailsCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "thumbnails",
Usage: "Start thumbnails server",
Category: "Extensions",
Flags: flagset.ServerWithConfig(cfg.Thumbnails),
Action: func(c *cli.Context) error {
thumbnailsCommand := command.Server(configureThumbnails(cfg))
if err := thumbnailsCommand.Before(c); err != nil {
return err
}
return cli.HandleAction(thumbnailsCommand.Action, c)
},
}
}
func configureThumbnails(cfg *config.Config) *svcconfig.Config {
cfg.Thumbnails.Log.Level = cfg.Log.Level
cfg.Thumbnails.Log.Pretty = cfg.Log.Pretty
cfg.Thumbnails.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.Thumbnails.Tracing.Enabled = cfg.Tracing.Enabled
cfg.Thumbnails.Tracing.Type = cfg.Tracing.Type
cfg.Thumbnails.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.Thumbnails.Tracing.Collector = cfg.Tracing.Collector
cfg.Thumbnails.Tracing.Service = cfg.Tracing.Service
}
return cfg.Thumbnails
}
func init() {
register.AddCommand(ThumbnailsCommand)
}
+51
View File
@@ -0,0 +1,51 @@
// +build !simple
package command
import (
"github.com/micro/cli/v2"
"github.com/owncloud/ocis/webdav/pkg/command"
svcconfig "github.com/owncloud/ocis/webdav/pkg/config"
"github.com/owncloud/ocis/webdav/pkg/flagset"
"github.com/owncloud/ocis/ocis/pkg/config"
"github.com/owncloud/ocis/ocis/pkg/register"
)
// WebDAVCommand is the entrypoint for the webdav command.
func WebDAVCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "webdav",
Usage: "Start webdav server",
Category: "Extensions",
Flags: flagset.ServerWithConfig(cfg.WebDAV),
Action: func(c *cli.Context) error {
webdavCommand := command.Server(configureWebDAV(cfg))
if err := webdavCommand.Before(c); err != nil {
return err
}
return cli.HandleAction(webdavCommand.Action, c)
},
}
}
func configureWebDAV(cfg *config.Config) *svcconfig.Config {
cfg.WebDAV.Log.Level = cfg.Log.Level
cfg.WebDAV.Log.Pretty = cfg.Log.Pretty
cfg.WebDAV.Log.Color = cfg.Log.Color
if cfg.Tracing.Enabled {
cfg.WebDAV.Tracing.Enabled = cfg.Tracing.Enabled
cfg.WebDAV.Tracing.Type = cfg.Tracing.Type
cfg.WebDAV.Tracing.Endpoint = cfg.Tracing.Endpoint
cfg.WebDAV.Tracing.Collector = cfg.Tracing.Collector
cfg.WebDAV.Tracing.Service = cfg.Tracing.Service
}
return cfg.WebDAV
}
func init() {
register.AddCommand(WebDAVCommand)
}