simplify commands and version handling

This commit is contained in:
Willy Kloucek
2022-01-03 13:53:27 +01:00
committed by Jörn Friedrich Dreyer
parent 5b70d46213
commit 23e7a8ffab
42 changed files with 873 additions and 499 deletions

View File

@@ -7,6 +7,7 @@ import (
"strings"
"github.com/owncloud/ocis/accounts/pkg/config"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
"github.com/owncloud/ocis/ocis-pkg/version"
@@ -14,49 +15,45 @@ import (
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
AddAccount(cfg),
UpdateAccount(cfg),
ListAccounts(cfg),
InspectAccount(cfg),
RemoveAccount(cfg),
RebuildIndex(cfg),
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the ocis-accounts command.
func Execute(cfg *config.Config) error {
app := &cli.App{
Name: "ocis-accounts",
Version: version.String,
Usage: "Provide accounts and groups for oCIS",
Compiled: version.Compiled(),
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
app := clihelper.DefaultApp(&cli.App{
Name: "ocis-accounts",
Usage: "Provide accounts and groups for oCIS",
Before: func(c *cli.Context) error {
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Commands: []*cli.Command{
Server(cfg),
AddAccount(cfg),
UpdateAccount(cfg),
ListAccounts(cfg),
InspectAccount(cfg),
RemoveAccount(cfg),
RebuildIndex(cfg),
Health(cfg),
PrintVersion(cfg),
},
}
Commands: GetCommands(cfg),
})
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)
}

View File

@@ -5,27 +5,32 @@ import (
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/version"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/accounts/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
// Version prints the service versions of all running instances.
func Version(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Action: func(c *cli.Context) error {
fmt.Println("Version: " + version.String)
fmt.Printf("Compiled: %s\n", version.Compiled())
fmt.Println("")
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.GRPC.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get accounts services from the registry: %v", err))
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
return err
}
if len(services) == 0 {
fmt.Println("No running accounts service found.")
fmt.Println("No running " + cfg.Service.Name + " service found.")
return nil
}

View File

@@ -6,6 +6,7 @@ import (
"os"
"github.com/owncloud/ocis/glauth/pkg/config"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
"github.com/owncloud/ocis/ocis-pkg/version"
@@ -13,41 +14,39 @@ import (
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the ocis-glauth command.
func Execute(cfg *config.Config) error {
app := &cli.App{
Name: "ocis-glauth",
Version: version.String,
Usage: "Serve GLAuth API for oCIS",
Compiled: version.Compiled(),
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
app := clihelper.DefaultApp(&cli.App{
Name: "ocis-glauth",
Usage: "Serve GLAuth API for oCIS",
Before: func(c *cli.Context) error {
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Commands: []*cli.Command{
Server(cfg),
Health(cfg),
},
}
Commands: GetCommands(cfg),
})
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)
}

View File

@@ -5,30 +5,32 @@ import (
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/version"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/glauth/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
// Version prints the service versions of all running instances.
func Version(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
fmt.Println("Version: " + version.String)
fmt.Printf("Compiled: %s\n", version.Compiled())
fmt.Println("")
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.Ldaps.Namespace + "." + cfg.Service.Name)
services, err := reg.GetService(cfg.Ldap.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get glauth services from the registry: %v", err))
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
return err
}
if len(services) == 0 {
fmt.Println("No running glauth service found.")
fmt.Println("No running " + cfg.Service.Name + " service found.")
return nil
}

View File

@@ -6,6 +6,7 @@ import (
"os"
"github.com/owncloud/ocis/graph-explorer/pkg/config"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
"github.com/owncloud/ocis/ocis-pkg/version"
@@ -13,38 +14,38 @@ import (
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the graph-explorer command.
func Execute(cfg *config.Config) error {
app := &cli.App{
Name: "graph-explorer",
Version: version.String,
Usage: "Serve Graph-Explorer for oCIS",
Compiled: version.Compiled(),
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
app := clihelper.DefaultApp(&cli.App{
Name: "graph-explorer",
Usage: "Serve Graph-Explorer for oCIS",
Before: func(c *cli.Context) error {
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Commands: []*cli.Command{
Server(cfg),
Health(cfg),
},
}
Commands: GetCommands(cfg),
})
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)
}

View File

@@ -5,30 +5,32 @@ import (
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/version"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/graph-explorer/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
// Version prints the service versions of all running instances.
func Version(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
fmt.Println("Version: " + version.String)
fmt.Printf("Compiled: %s\n", version.Compiled())
fmt.Println("")
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get graph services from the registry: %v", err))
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
return err
}
if len(services) == 0 {
fmt.Println("No running graph service found.")
fmt.Println("No running " + cfg.Service.Name + " service found.")
return nil
}

View File

@@ -5,6 +5,7 @@ import (
"errors"
"os"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
"github.com/thejerf/suture/v4"
@@ -14,38 +15,37 @@ import (
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the ocis-graph command.
func Execute(cfg *config.Config) error {
app := &cli.App{
Name: "ocis-graph",
Version: version.String,
Usage: "Serve Graph API for oCIS",
Compiled: version.Compiled(),
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
app := clihelper.DefaultApp(&cli.App{
Name: "ocis-graph",
Usage: "Serve Graph API for oCIS",
Before: func(c *cli.Context) error {
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Commands: []*cli.Command{
Server(cfg),
Health(cfg),
},
}
Commands: GetCommands(cfg),
})
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)
}

View File

@@ -5,30 +5,32 @@ import (
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/version"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/graph/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
// Version prints the service versions of all running instances.
func Version(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
fmt.Println("Version: " + version.String)
fmt.Printf("Compiled: %s\n", version.Compiled())
fmt.Println("")
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get graph services from the registry: %v", err))
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
return err
}
if len(services) == 0 {
fmt.Println("No running graph service found.")
fmt.Println("No running " + cfg.Service.Name + " service found.")
return nil
}

View File

@@ -33,7 +33,6 @@ type Spaces struct {
DefaultQuota string `ocisConfig:"default_quota" env:"GRAPH_SPACES_DEFAULT_QUOTA"`
}
// TODO: do we really need a ldap backend if CS3 also does LDAP!?
type LDAP struct {
URI string `ocisConfig:"uri" env:"GRAPH_LDAP_URI"`
BindDN string `ocisConfig:"bind_dn" env:"GRAPH_LDAP_BIND_DN"`

View File

@@ -6,6 +6,7 @@ import (
"os"
"github.com/owncloud/ocis/idp/pkg/config"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
"github.com/owncloud/ocis/ocis-pkg/version"
@@ -13,42 +14,39 @@ import (
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the ocis-idp command.
func Execute(cfg *config.Config) error {
app := &cli.App{
Name: "ocis-idp",
Version: version.String,
Usage: "Serve IDP API for oCIS",
Compiled: version.Compiled(),
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
app := clihelper.DefaultApp(&cli.App{
Name: "ocis-idp",
Usage: "Serve IDP API for oCIS",
Before: func(c *cli.Context) error {
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Commands: []*cli.Command{
Server(cfg),
Health(cfg),
PrintVersion(cfg),
},
}
Commands: GetCommands(cfg),
})
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)
}

View File

@@ -5,30 +5,32 @@ import (
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/version"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/idp/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
// Version prints the service versions of all running instances.
func Version(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
fmt.Println("Version: " + version.String)
fmt.Printf("Compiled: %s\n", version.Compiled())
fmt.Println("")
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get idp services from the registry: %v", err))
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
return err
}
if len(services) == 0 {
fmt.Println("No running idp service found.")
fmt.Println("No running " + cfg.Service.Name + " service found.")
return nil
}

26
ocis-pkg/clihelper/app.go Normal file
View File

@@ -0,0 +1,26 @@
package clihelper
import (
"github.com/owncloud/ocis/ocis-pkg/version"
"github.com/urfave/cli/v2"
)
func DefaultApp(app *cli.App) *cli.App {
// version info
app.Version = version.String
app.Compiled = version.Compiled()
// author info
app.Authors = []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
}
// disable global version flag
// instead we provide the version command
app.HideVersion = true
return app
}

View File

@@ -13,14 +13,6 @@ func AccountsCommand(cfg *config.Config) *cli.Command {
Name: "accounts",
Usage: "Start accounts server",
Category: "Extensions",
Subcommands: []*cli.Command{
command.ListAccounts(cfg.Accounts),
command.AddAccount(cfg.Accounts),
command.UpdateAccount(cfg.Accounts),
command.RemoveAccount(cfg.Accounts),
command.InspectAccount(cfg.Accounts),
command.PrintVersion(cfg.Accounts),
},
Before: func(ctx *cli.Context) error {
if err := ParseConfig(ctx, cfg); err != nil {
return err
@@ -32,10 +24,7 @@ func AccountsCommand(cfg *config.Config) *cli.Command {
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Server(cfg.Accounts)
return handleOriginalAction(c, origCmd)
},
Subcommands: command.GetCommands(cfg.Accounts),
}
}

View File

@@ -24,10 +24,7 @@ func GLAuthCommand(cfg *config.Config) *cli.Command {
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Server(cfg.GLAuth)
return handleOriginalAction(c, origCmd)
},
Subcommands: command.GetCommands(cfg.GLAuth),
}
}

View File

@@ -19,18 +19,12 @@ func GraphCommand(cfg *config.Config) *cli.Command {
}
if cfg.Commons != nil {
cfg.Graph.Commons = cfg.Commons
cfg.Accounts.Commons = cfg.Commons
}
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Server(cfg.Graph)
return handleOriginalAction(c, origCmd)
},
Subcommands: []*cli.Command{
command.PrintVersion(cfg.Graph),
},
Subcommands: command.GetCommands(cfg.Graph),
}
}

View File

@@ -19,18 +19,12 @@ func GraphExplorerCommand(cfg *config.Config) *cli.Command {
}
if cfg.Commons != nil {
cfg.Graph.Commons = cfg.Commons
cfg.GraphExplorer.Commons = cfg.Commons
}
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Server(cfg.GraphExplorer)
return handleOriginalAction(c, origCmd)
},
Subcommands: []*cli.Command{
command.PrintVersion(cfg.GraphExplorer),
},
Subcommands: command.GetCommands(cfg.GraphExplorer),
}
}

View File

@@ -13,9 +13,6 @@ func IDPCommand(cfg *config.Config) *cli.Command {
Name: "idp",
Usage: "Start idp server",
Category: "Extensions",
Subcommands: []*cli.Command{
command.PrintVersion(cfg.IDP),
},
Before: func(ctx *cli.Context) error {
if err := ParseConfig(ctx, cfg); err != nil {
return err
@@ -27,14 +24,7 @@ func IDPCommand(cfg *config.Config) *cli.Command {
return nil
},
Action: func(c *cli.Context) error {
idpCommand := command.Server(cfg.IDP)
if err := idpCommand.Before(c); err != nil {
return err
}
return cli.HandleAction(idpCommand.Action, c)
},
Subcommands: command.GetCommands(cfg.IDP),
}
}

View File

@@ -24,13 +24,7 @@ func OCSCommand(cfg *config.Config) *cli.Command {
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Server(cfg.OCS)
return handleOriginalAction(c, origCmd)
},
Subcommands: []*cli.Command{
command.PrintVersion(cfg.OCS),
},
Subcommands: command.GetCommands(cfg.OCS),
}
}

View File

@@ -13,9 +13,6 @@ func ProxyCommand(cfg *config.Config) *cli.Command {
Name: "proxy",
Usage: "Start proxy server",
Category: "Extensions",
Subcommands: []*cli.Command{
command.PrintVersion(cfg.Proxy),
},
Before: func(ctx *cli.Context) error {
if err := ParseConfig(ctx, cfg); err != nil {
return err
@@ -27,10 +24,7 @@ func ProxyCommand(cfg *config.Config) *cli.Command {
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Server(cfg.Proxy)
return handleOriginalAction(c, origCmd)
},
Subcommands: command.GetCommands(cfg.Proxy),
}
}

View File

@@ -4,10 +4,10 @@ import (
"errors"
"os"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
"github.com/owncloud/ocis/ocis-pkg/shared"
"github.com/owncloud/ocis/ocis-pkg/version"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/urfave/cli/v2"
)
@@ -16,24 +16,16 @@ import (
func Execute() error {
cfg := config.DefaultConfig()
app := &cli.App{
Name: "ocis",
Version: version.String,
Usage: "ownCloud Infinite Scale Stack",
Compiled: version.Compiled(),
app := clihelper.DefaultApp(&cli.App{
Name: "ocis",
Usage: "ownCloud Infinite Scale Stack",
Before: func(c *cli.Context) error {
// TODO: what do do?
//cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
}
})
for _, fn := range register.Commands {
app.Commands = append(
@@ -47,11 +39,6 @@ func Execute() error {
Usage: "Show the help",
}
cli.VersionFlag = &cli.BoolFlag{
Name: "version,v",
Usage: "Print the version",
}
return app.Run(os.Args)
}

View File

@@ -13,9 +13,6 @@ func SettingsCommand(cfg *config.Config) *cli.Command {
Name: "settings",
Usage: "Start settings server",
Category: "Extensions",
Subcommands: []*cli.Command{
command.PrintVersion(cfg.Settings),
},
Before: func(ctx *cli.Context) error {
if err := ParseConfig(ctx, cfg); err != nil {
return err
@@ -27,10 +24,7 @@ func SettingsCommand(cfg *config.Config) *cli.Command {
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Server(cfg.Settings)
return handleOriginalAction(c, origCmd)
},
Subcommands: command.GetCommands(cfg.Settings),
}
}

View File

@@ -9,36 +9,23 @@ import (
// StoreCommand is the entrypoint for the ocs command.
func StoreCommand(cfg *config.Config) *cli.Command {
//var globalLog shared.Log
return &cli.Command{
Name: "store",
Usage: "Start a go-micro store",
Category: "Extensions",
Subcommands: []*cli.Command{
command.PrintVersion(cfg.Store),
},
Before: func(ctx *cli.Context) error {
if err := ParseConfig(ctx, cfg); err != nil {
return err
}
// TODO: what to do
//globalLog = cfg.Log
if cfg.Commons != nil {
cfg.Store.Commons = cfg.Commons
}
return nil
},
Action: func(c *cli.Context) error {
// TODO: what to do
// if accounts logging is empty in ocis.yaml
//if (cfg.Store.Log == shared.Log{}) && (globalLog != shared.Log{}) {
// // we can safely inherit the global logging values.
// cfg.Store.Log = globalLog
//}
origCmd := command.Server(cfg.Store)
return handleOriginalAction(c, origCmd)
},
Subcommands: command.GetCommands(cfg.Store),
}
}

View File

@@ -13,9 +13,6 @@ func ThumbnailsCommand(cfg *config.Config) *cli.Command {
Name: "thumbnails",
Usage: "Start thumbnails server",
Category: "Extensions",
Subcommands: []*cli.Command{
command.PrintVersion(cfg.Thumbnails),
},
Before: func(ctx *cli.Context) error {
if err := ParseConfig(ctx, cfg); err != nil {
return err
@@ -31,6 +28,7 @@ func ThumbnailsCommand(cfg *config.Config) *cli.Command {
origCmd := command.Server(cfg.Thumbnails)
return handleOriginalAction(c, origCmd)
},
Subcommands: command.GetCommands(cfg.Thumbnails),
}
}

View File

@@ -7,6 +7,7 @@ import (
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/version"
"github.com/owncloud/ocis/ocis/pkg/register"
"github.com/urfave/cli/v2"
mreg "go-micro.dev/v4/registry"
@@ -19,6 +20,10 @@ func VersionCommand(cfg *config.Config) *cli.Command {
Usage: "Lists running services with version",
Category: "Runtime",
Action: func(c *cli.Context) error {
fmt.Println("Version: " + version.String)
fmt.Printf("Compiled: %s\n", version.Compiled())
fmt.Println("")
reg := registry.GetRegistry()
serviceList, err := reg.ListServices()
if err != nil {

View File

@@ -24,10 +24,7 @@ func WebCommand(cfg *config.Config) *cli.Command {
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Server(cfg.Web)
return handleOriginalAction(c, origCmd)
},
Subcommands: command.GetCommands(cfg.Web),
}
}

View File

@@ -14,9 +14,6 @@ func WebDAVCommand(cfg *config.Config) *cli.Command {
Name: "webdav",
Usage: "Start webdav server",
Category: "Extensions",
Subcommands: []*cli.Command{
command.PrintVersion(cfg.WebDAV),
},
Before: func(ctx *cli.Context) error {
if err := ParseConfig(ctx, cfg); err != nil {
return err
@@ -28,10 +25,7 @@ func WebDAVCommand(cfg *config.Config) *cli.Command {
return nil
},
Action: func(c *cli.Context) error {
origCmd := command.Server(cfg.WebDAV)
return handleOriginalAction(c, origCmd)
},
Subcommands: command.GetCommands(cfg.WebDAV),
}
}

View File

@@ -5,6 +5,7 @@ import (
"errors"
"os"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
"github.com/owncloud/ocis/ocis-pkg/version"
@@ -13,43 +14,39 @@ import (
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the ocis-ocs command.
func Execute(cfg *config.Config) error {
app := &cli.App{
Name: "ocis-ocs",
Version: version.String,
Usage: "Serve OCS API for oCIS",
Compiled: version.Compiled(),
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
app := clihelper.DefaultApp(&cli.App{
Name: "ocis-ocs",
Usage: "Serve OCS API for oCIS",
Before: func(c *cli.Context) error {
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Commands: []*cli.Command{
Server(cfg),
Health(cfg),
PrintVersion(cfg),
},
}
Commands: GetCommands(cfg),
})
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)
}

View File

@@ -5,30 +5,32 @@ import (
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/version"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/ocs/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
// Version prints the service versions of all running instances.
func Version(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
fmt.Println("Version: " + version.String)
fmt.Printf("Compiled: %s\n", version.Compiled())
fmt.Println("")
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get ocs services from the registry: %v", err))
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
return err
}
if len(services) == 0 {
fmt.Println("No running ocs service found.")
fmt.Println("No running " + cfg.Service.Name + " service found.")
return nil
}

View File

@@ -5,6 +5,7 @@ import (
"errors"
"os"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
"github.com/owncloud/ocis/ocis-pkg/version"
@@ -13,42 +14,39 @@ import (
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the ocis-proxy command.
func Execute(cfg *config.Config) error {
app := &cli.App{
Name: "ocis-proxy",
Version: version.String,
Usage: "proxy for oCIS",
Compiled: version.Compiled(),
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
app := clihelper.DefaultApp(&cli.App{
Name: "ocis-proxy",
Usage: "proxy for oCIS",
Before: func(c *cli.Context) error {
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Commands: []*cli.Command{
Server(cfg),
Health(cfg),
PrintVersion(cfg),
},
}
Commands: GetCommands(cfg),
})
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)
}

View File

@@ -5,30 +5,32 @@ import (
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/version"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/proxy/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
// Version prints the service versions of all running instances.
func Version(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
fmt.Println("Version: " + version.String)
fmt.Printf("Compiled: %s\n", version.Compiled())
fmt.Println("")
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get proxy services from the registry: %v", err))
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
return err
}
if len(services) == 0 {
fmt.Println("No running proxy service found.")
fmt.Println("No running " + cfg.Service.Name + " service found.")
return nil
}

View File

@@ -5,6 +5,7 @@ import (
"errors"
"os"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
"github.com/owncloud/ocis/ocis-pkg/version"
@@ -13,43 +14,39 @@ import (
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the ocis-settings command.
func Execute(cfg *config.Config) error {
app := &cli.App{
Name: "ocis-settings",
Version: version.String,
Usage: "Provide settings and permissions for oCIS",
Compiled: version.Compiled(),
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
app := clihelper.DefaultApp(&cli.App{
Name: "ocis-settings",
Usage: "Provide settings and permissions for oCIS",
Before: func(c *cli.Context) error {
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Commands: []*cli.Command{
Server(cfg),
Health(cfg),
PrintVersion(cfg),
},
}
Commands: GetCommands(cfg),
})
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)
}

View File

@@ -5,30 +5,32 @@ import (
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/version"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/settings/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
// Version prints the service versions of all running instances.
func Version(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
fmt.Println("Version: " + version.String)
fmt.Printf("Compiled: %s\n", version.Compiled())
fmt.Println("")
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.GRPC.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get settings services from the registry: %v", err))
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
return err
}
if len(services) == 0 {
fmt.Println("No running settings service found.")
fmt.Println("No running " + cfg.Service.Name + " service found.")
return nil
}

View File

@@ -3,58 +3,50 @@ package command
import (
"os"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
"github.com/owncloud/ocis/ocis-pkg/log"
"github.com/owncloud/ocis/ocis-pkg/version"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
Frontend(cfg),
Gateway(cfg),
Users(cfg),
Groups(cfg),
AppProvider(cfg),
AuthBasic(cfg),
AuthBearer(cfg),
AuthMachine(cfg),
Sharing(cfg),
StoragePublicLink(cfg),
StorageShares(cfg),
StorageUsers(cfg),
StorageMetadata(cfg),
Health(cfg),
}
}
// Execute is the entry point for the storage command.
func Execute(cfg *config.Config) error {
app := &cli.App{
Name: "storage",
Version: version.String,
Usage: "Storage service for oCIS",
Compiled: version.Compiled(),
app := clihelper.DefaultApp(&cli.App{
Name: "storage",
Usage: "Storage service for oCIS",
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage")
},
Commands: []*cli.Command{
Frontend(cfg),
Gateway(cfg),
Users(cfg),
Groups(cfg),
AppProvider(cfg),
AuthBasic(cfg),
AuthBearer(cfg),
AuthMachine(cfg),
Sharing(cfg),
StorageUsers(cfg),
StorageShares(cfg),
StoragePublicLink(cfg),
StorageMetadata(cfg),
Health(cfg),
},
}
Commands: GetCommands(cfg),
})
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)
}

View File

@@ -0,0 +1,436 @@
package config
import (
"os"
"path"
"github.com/owncloud/ocis/ocis-pkg/config/defaults"
)
func DefaultConfig() *Config {
return &Config{
// log is inherited
Debug: Debug{
Addr: "127.0.0.1:9109",
},
Reva: Reva{
JWTSecret: "Pive-Fumkiu4",
SkipUserGroupsInToken: false,
TransferSecret: "replace-me-with-a-transfer-secret",
TransferExpires: 24 * 60 * 60,
OIDC: OIDC{
Issuer: "https://localhost:9200",
Insecure: false,
IDClaim: "preferred_username",
},
LDAP: LDAP{
Hostname: "localhost",
Port: 9126,
CACert: path.Join(defaults.BaseDataPath(), "ldap", "ldap.crt"),
Insecure: false,
BaseDN: "dc=ocis,dc=test",
LoginFilter: "(&(objectclass=posixAccount)(|(cn={{login}})(mail={{login}})))",
UserFilter: "(&(objectclass=posixAccount)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))",
UserAttributeFilter: "(&(objectclass=posixAccount)({{attr}}={{value}}))",
UserFindFilter: "(&(objectclass=posixAccount)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))",
UserGroupFilter: "(&(objectclass=posixGroup)(ownclouduuid={{.OpaqueId}}*))",
GroupFilter: "(&(objectclass=posixGroup)(|(ownclouduuid={{.OpaqueId}})(cn={{.OpaqueId}})))",
GroupAttributeFilter: "(&(objectclass=posixGroup)({{attr}}={{value}}))",
GroupFindFilter: "(&(objectclass=posixGroup)(|(cn={{query}}*)(displayname={{query}}*)(mail={{query}}*)))",
GroupMemberFilter: "(&(objectclass=posixAccount)(ownclouduuid={{.OpaqueId}}*))",
BindDN: "cn=reva,ou=sysusers,dc=ocis,dc=test",
BindPassword: "reva",
IDP: "https://localhost:9200",
UserSchema: LDAPUserSchema{
UID: "ownclouduuid",
Mail: "mail",
DisplayName: "displayname",
CN: "cn",
UIDNumber: "uidnumber",
GIDNumber: "gidnumber",
},
GroupSchema: LDAPGroupSchema{
GID: "cn",
Mail: "mail",
DisplayName: "cn",
CN: "cn",
GIDNumber: "gidnumber",
},
},
UserGroupRest: UserGroupRest{
RedisAddress: "localhost:6379",
},
UserOwnCloudSQL: UserOwnCloudSQL{
DBUsername: "owncloud",
DBPassword: "secret",
DBHost: "mysql",
DBPort: 3306,
DBName: "owncloud",
Idp: "https://localhost:9200",
Nobody: 90,
JoinUsername: false,
JoinOwnCloudUUID: false,
EnableMedialSearch: false,
},
OCDav: OCDav{
WebdavNamespace: "/users/{{.Id.OpaqueId}}",
DavFilesNamespace: "/users/{{.Id.OpaqueId}}",
},
Archiver: Archiver{
MaxNumFiles: 10000,
MaxSize: 1073741824,
ArchiverURL: "/archiver",
},
UserStorage: StorageConfig{
EOS: DriverEOS{
DriverCommon: DriverCommon{
Root: "/eos/dockertest/reva",
ShareFolder: "/Shares",
UserLayout: "{{substr 0 1 .Username}}/{{.Username}}",
},
ShadowNamespace: "", // Defaults to path.Join(c.Namespace, ".shadow")
UploadsNamespace: "", // Defaults to path.Join(c.Namespace, ".uploads")
EosBinary: "/usr/bin/eos",
XrdcopyBinary: "/usr/bin/xrdcopy",
MasterURL: "root://eos-mgm1.eoscluster.cern.ch:1094",
SlaveURL: "root://eos-mgm1.eoscluster.cern.ch:1094",
CacheDirectory: os.TempDir(),
GatewaySVC: "127.0.0.1:9142",
},
Local: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "local", "users"),
ShareFolder: "/Shares",
UserLayout: "{{.Username}}",
EnableHome: false,
},
OwnCloud: DriverOwnCloud{
DriverCommon: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "owncloud"),
ShareFolder: "/Shares",
UserLayout: "{{.Id.OpaqueId}}",
EnableHome: false,
},
UploadInfoDir: path.Join(defaults.BaseDataPath(), "storage", "uploadinfo"),
Redis: ":6379",
Scan: true,
},
OwnCloudSQL: DriverOwnCloudSQL{
DriverCommon: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "owncloud"),
ShareFolder: "/Shares",
UserLayout: "{{.Username}}",
EnableHome: false,
},
UploadInfoDir: path.Join(defaults.BaseDataPath(), "storage", "uploadinfo"),
DBUsername: "owncloud",
DBPassword: "owncloud",
DBHost: "",
DBPort: 3306,
DBName: "owncloud",
},
S3: DriverS3{
DriverCommon: DriverCommon{},
Region: "default",
AccessKey: "",
SecretKey: "",
Endpoint: "",
Bucket: "",
},
S3NG: DriverS3NG{
DriverCommon: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "users"),
ShareFolder: "/Shares",
UserLayout: "{{.Id.OpaqueId}}",
EnableHome: false,
},
ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad",
Region: "default",
AccessKey: "",
SecretKey: "",
Endpoint: "",
Bucket: "",
},
OCIS: DriverOCIS{
DriverCommon: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "users"),
ShareFolder: "/Shares",
UserLayout: "{{.Id.OpaqueId}}",
},
ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad",
},
},
MetadataStorage: StorageConfig{
EOS: DriverEOS{
DriverCommon: DriverCommon{
Root: "/eos/dockertest/reva",
ShareFolder: "/Shares",
UserLayout: "{{substr 0 1 .Username}}/{{.Username}}",
EnableHome: false,
},
ShadowNamespace: "",
UploadsNamespace: "",
EosBinary: "/usr/bin/eos",
XrdcopyBinary: "/usr/bin/xrdcopy",
MasterURL: "root://eos-mgm1.eoscluster.cern.ch:1094",
GrpcURI: "",
SlaveURL: "root://eos-mgm1.eoscluster.cern.ch:1094",
CacheDirectory: os.TempDir(),
EnableLogging: false,
ShowHiddenSysFiles: false,
ForceSingleUserMode: false,
UseKeytab: false,
SecProtocol: "",
Keytab: "",
SingleUsername: "",
GatewaySVC: "127.0.0.1:9142",
},
Local: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "local", "metadata"),
},
OwnCloud: DriverOwnCloud{},
OwnCloudSQL: DriverOwnCloudSQL{},
S3: DriverS3{
DriverCommon: DriverCommon{},
Region: "default",
},
S3NG: DriverS3NG{
DriverCommon: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "metadata"),
ShareFolder: "",
UserLayout: "{{.Id.OpaqueId}}",
EnableHome: false,
},
ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad",
Region: "default",
AccessKey: "",
SecretKey: "",
Endpoint: "",
Bucket: "",
},
OCIS: DriverOCIS{
DriverCommon: DriverCommon{
Root: path.Join(defaults.BaseDataPath(), "storage", "metadata"),
ShareFolder: "",
UserLayout: "{{.Id.OpaqueId}}",
EnableHome: false,
},
ServiceUserUUID: "95cb8724-03b2-11eb-a0a6-c33ef8ef53ad",
},
},
Frontend: FrontendPort{
Port: Port{
MaxCPUs: "",
LogLevel: "",
GRPCNetwork: "",
GRPCAddr: "",
HTTPNetwork: "tcp",
HTTPAddr: "127.0.0.1:9140",
Protocol: "",
Endpoint: "",
DebugAddr: "127.0.0.1:9141",
Services: []string{"datagateway", "ocdav", "ocs", "appprovider"},
Config: nil,
Context: nil,
Supervised: false,
},
AppProviderInsecure: false,
AppProviderPrefix: "",
ArchiverInsecure: false,
ArchiverPrefix: "archiver",
DatagatewayPrefix: "data",
Favorites: false,
OCDavInsecure: false,
OCDavPrefix: "",
OCSPrefix: "ocs",
OCSSharePrefix: "/Shares",
OCSHomeNamespace: "/users/{{.Id.OpaqueId}}",
PublicURL: "https://localhost:9200",
OCSCacheWarmupDriver: "",
OCSAdditionalInfoAttribute: "{{.Mail}}",
OCSResourceInfoCacheTTL: 0,
Middleware: Middleware{},
},
DataGateway: DataGatewayPort{
Port: Port{},
PublicURL: "",
},
Gateway: Gateway{
Port: Port{
Endpoint: "127.0.0.1:9142",
DebugAddr: "127.0.0.1:9143",
GRPCNetwork: "tcp",
GRPCAddr: "127.0.0.1:9142",
},
CommitShareToStorageGrant: true,
CommitShareToStorageRef: true,
DisableHomeCreationOnLogin: false,
ShareFolder: "Shares",
LinkGrants: "",
HomeMapping: "",
EtagCacheTTL: 0,
},
StorageRegistry: StorageRegistry{
Driver: "spaces",
HomeProvider: "/home",
JSON: "",
},
AppRegistry: AppRegistry{
Driver: "static",
MimetypesJSON: "",
},
Users: Users{
Port: Port{
Endpoint: "localhost:9144",
DebugAddr: "127.0.0.1:9145",
GRPCNetwork: "tcp",
GRPCAddr: "127.0.0.1:9144",
Services: []string{"userprovider"},
},
Driver: "ldap",
UserGroupsCacheExpiration: 5,
},
Groups: Groups{
Port: Port{
Endpoint: "localhost:9160",
DebugAddr: "127.0.0.1:9161",
GRPCNetwork: "tcp",
GRPCAddr: "127.0.0.1:9160",
Services: []string{"groupprovider"},
},
Driver: "ldap",
GroupMembersCacheExpiration: 5,
},
AuthProvider: Users{
Port: Port{},
Driver: "ldap",
UserGroupsCacheExpiration: 0,
},
AuthBasic: Port{
GRPCNetwork: "tcp",
GRPCAddr: "127.0.0.1:9146",
DebugAddr: "127.0.0.1:9147",
Services: []string{"authprovider"},
Endpoint: "localhost:9146",
},
AuthBearer: Port{
GRPCNetwork: "tcp",
GRPCAddr: "127.0.0.1:9148",
DebugAddr: "127.0.0.1:9149",
Services: []string{"authprovider"},
Endpoint: "localhost:9148",
},
AuthMachine: Port{
GRPCNetwork: "tcp",
GRPCAddr: "127.0.0.1:9166",
DebugAddr: "127.0.0.1:9167",
Services: []string{"authprovider"},
Endpoint: "localhost:9166",
},
AuthMachineConfig: AuthMachineConfig{
MachineAuthAPIKey: "change-me-please",
},
Sharing: Sharing{
Port: Port{
Endpoint: "localhost:9150",
DebugAddr: "127.0.0.1:9151",
GRPCNetwork: "tcp",
GRPCAddr: "127.0.0.1:9150",
Services: []string{"usershareprovider", "publicshareprovider"},
},
UserDriver: "json",
UserJSONFile: path.Join(defaults.BaseDataPath(), "storage", "shares.json"),
UserSQLUsername: "",
UserSQLPassword: "",
UserSQLHost: "",
UserSQLPort: 1433,
UserSQLName: "",
PublicDriver: "json",
PublicJSONFile: path.Join(defaults.BaseDataPath(), "storage", "publicshares.json"),
PublicPasswordHashCost: 11,
PublicEnableExpiredSharesCleanup: true,
PublicJanitorRunInterval: 60,
UserStorageMountID: "",
},
StorageShares: StoragePort{
Port: Port{
Endpoint: "localhost:9154",
DebugAddr: "127.0.0.1:9156",
GRPCNetwork: "tcp",
GRPCAddr: "127.0.0.1:9154",
HTTPNetwork: "tcp",
HTTPAddr: "127.0.0.1:9155",
},
ReadOnly: false,
AlternativeID: "1284d238-aa92-42ce-bdc4-0b0000009154",
MountID: "1284d238-aa92-42ce-bdc4-0b0000009157",
},
StorageUsers: StoragePort{
Port: Port{
Endpoint: "localhost:9157",
DebugAddr: "127.0.0.1:9159",
GRPCNetwork: "tcp",
GRPCAddr: "127.0.0.1:9157",
HTTPNetwork: "tcp",
HTTPAddr: "127.0.0.1:9158",
},
MountID: "1284d238-aa92-42ce-bdc4-0b0000009157",
Driver: "ocis",
DataServerURL: "http://localhost:9158/data",
HTTPPrefix: "data",
TempFolder: path.Join(defaults.BaseDataPath(), "tmp", "users"),
},
StoragePublicLink: PublicStorage{
StoragePort: StoragePort{
Port: Port{
Endpoint: "localhost:9178",
DebugAddr: "127.0.0.1:9179",
GRPCNetwork: "tcp",
GRPCAddr: "127.0.0.1:9178",
},
MountID: "e1a73ede-549b-4226-abdf-40e69ca8230d",
},
PublicShareProviderAddr: "",
UserProviderAddr: "",
},
StorageMetadata: StoragePort{
Port: Port{
GRPCNetwork: "tcp",
GRPCAddr: "127.0.0.1:9215",
HTTPNetwork: "tcp",
HTTPAddr: "127.0.0.1:9216",
DebugAddr: "127.0.0.1:9217",
},
Driver: "ocis",
ExposeDataServer: false,
DataServerURL: "http://localhost:9216/data",
TempFolder: path.Join(defaults.BaseDataPath(), "tmp", "metadata"),
DataProvider: DataProvider{},
},
AppProvider: AppProvider{
Port: Port{
GRPCNetwork: "tcp",
GRPCAddr: "127.0.0.1:9164",
DebugAddr: "127.0.0.1:9165",
Endpoint: "localhost:9164",
Services: []string{"appprovider"},
},
ExternalAddr: "127.0.0.1:9164",
WopiDriver: WopiDriver{},
AppsURL: "/app/list",
OpenURL: "/app/open",
NewURL: "/app/new",
},
Configs: nil,
UploadMaxChunkSize: 1e+8,
UploadHTTPMethodOverride: "",
ChecksumSupportedTypes: []string{"sha1", "md5", "adler32"},
ChecksumPreferredUploadType: "",
DefaultUploadProtocol: "tus",
},
Tracing: Tracing{
Service: "storage",
Type: "jaeger",
},
Asset: Asset{},
}
}

View File

@@ -5,6 +5,7 @@ import (
"errors"
"os"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
"github.com/owncloud/ocis/ocis-pkg/version"
@@ -13,43 +14,39 @@ import (
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the ocis-store command.
func Execute(cfg *config.Config) error {
app := &cli.App{
Name: "ocis-store",
Version: version.String,
Usage: "Service to store values for ocis extensions",
Compiled: version.Compiled(),
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
app := clihelper.DefaultApp(&cli.App{
Name: "ocis-store",
Usage: "Service to store values for ocis extensions",
Before: func(c *cli.Context) error {
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Commands: []*cli.Command{
Server(cfg),
Health(cfg),
PrintVersion(cfg),
},
}
Commands: GetCommands(cfg),
})
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)
}

View File

@@ -5,30 +5,32 @@ import (
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/version"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/store/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
// Version prints the service versions of all running instances.
func Version(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
fmt.Println("Version: " + version.String)
fmt.Printf("Compiled: %s\n", version.Compiled())
fmt.Println("")
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.GRPC.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get store services from the registry: %v", err))
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
return err
}
if len(services) == 0 {
fmt.Println("No running store service found.")
fmt.Println("No running " + cfg.Service.Name + " service found.")
return nil
}

View File

@@ -5,6 +5,7 @@ import (
"errors"
"os"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
"github.com/owncloud/ocis/ocis-pkg/version"
@@ -13,43 +14,39 @@ import (
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the ocis-thumbnails command.
func Execute(cfg *config.Config) error {
app := &cli.App{
Name: "ocis-thumbnails",
Version: version.String,
Usage: "Example usage",
Compiled: version.Compiled(),
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
app := clihelper.DefaultApp(&cli.App{
Name: "ocis-thumbnails",
Usage: "Example usage",
Before: func(c *cli.Context) error {
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Commands: []*cli.Command{
Server(cfg),
Health(cfg),
PrintVersion(cfg),
},
}
Commands: GetCommands(cfg),
})
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)
}

View File

@@ -5,30 +5,32 @@ import (
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/version"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/thumbnails/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
// Version prints the service versions of all running instances.
func Version(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
fmt.Println("Version: " + version.String)
fmt.Printf("Compiled: %s\n", version.Compiled())
fmt.Println("")
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.GRPC.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get thumbnails services from the registry: %v", err))
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
return err
}
if len(services) == 0 {
fmt.Println("No running thumbnails service found.")
fmt.Println("No running " + cfg.Service.Name + " service found.")
return nil
}

View File

@@ -5,6 +5,7 @@ import (
"errors"
"os"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
"github.com/owncloud/ocis/ocis-pkg/version"
@@ -13,46 +14,45 @@ import (
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the web command.
func Execute(cfg *config.Config) error {
app := &cli.App{
Name: "web",
Version: version.String,
Usage: "Serve ownCloud Web for oCIS",
Compiled: version.Compiled(),
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
app := clihelper.DefaultApp(&cli.App{
Name: "web",
Usage: "Serve ownCloud Web for oCIS",
Before: func(c *cli.Context) error {
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Commands: []*cli.Command{
Server(cfg),
Health(cfg),
},
}
Commands: GetCommands(cfg),
})
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)
}
// ParseConfig loads accounts configuration from known paths.
func ParseConfig(c *cli.Context, cfg *config.Config) error {
// TODO: remove cli.Context
_, err := ociscfg.BindSourcesToStructs(cfg.Service.Name, cfg)
if err != nil {
return err

View File

@@ -5,30 +5,32 @@ import (
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/version"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/web/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
// Version prints the service versions of all running instances.
func Version(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
fmt.Println("Version: " + version.String)
fmt.Printf("Compiled: %s\n", version.Compiled())
fmt.Println("")
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get web services from the registry: %v", err))
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
return err
}
if len(services) == 0 {
fmt.Println("No running web service found.")
fmt.Println("No running " + cfg.Service.Name + " service found.")
return nil
}

View File

@@ -5,6 +5,7 @@ import (
"errors"
"os"
"github.com/owncloud/ocis/ocis-pkg/clihelper"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/ocis-pkg/config/envdecode"
"github.com/owncloud/ocis/ocis-pkg/version"
@@ -13,41 +14,39 @@ import (
"github.com/urfave/cli/v2"
)
// GetCommands provides all commands for this service
func GetCommands(cfg *config.Config) cli.Commands {
return []*cli.Command{
// start this service
Server(cfg),
// interaction with this service
// infos about this service
Health(cfg),
Version(cfg),
}
}
// Execute is the entry point for the ocis-webdav command.
func Execute(cfg *config.Config) error {
app := &cli.App{
Name: "webdav",
Version: version.String,
Usage: "Serve WebDAV API for oCIS",
Compiled: version.Compiled(),
app := clihelper.DefaultApp(&cli.App{
Name: "webdav",
Usage: "Serve WebDAV API for oCIS",
Authors: []*cli.Author{
{
Name: "ownCloud GmbH",
Email: "support@owncloud.com",
},
},
Before: func(c *cli.Context) error {
cfg.Service.Version = version.String
return ParseConfig(c, cfg)
},
Commands: []*cli.Command{
Server(cfg),
Health(cfg),
},
}
Commands: GetCommands(cfg),
})
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)
}

View File

@@ -5,30 +5,32 @@ import (
"os"
"github.com/owncloud/ocis/ocis-pkg/registry"
"github.com/owncloud/ocis/ocis-pkg/version"
tw "github.com/olekukonko/tablewriter"
"github.com/owncloud/ocis/webdav/pkg/config"
"github.com/urfave/cli/v2"
)
// PrintVersion prints the service versions of all running instances.
func PrintVersion(cfg *config.Config) *cli.Command {
// Version prints the service versions of all running instances.
func Version(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "version",
Usage: "Print the versions of the running instances",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg)
},
Action: func(c *cli.Context) error {
fmt.Println("Version: " + version.String)
fmt.Printf("Compiled: %s\n", version.Compiled())
fmt.Println("")
reg := registry.GetRegistry()
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
if err != nil {
fmt.Println(fmt.Errorf("could not get webdav services from the registry: %v", err))
fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
return err
}
if len(services) == 0 {
fmt.Println("No running webdav service found.")
fmt.Println("No running " + cfg.Service.Name + " service found.")
return nil
}