Merge pull request #2818 from owncloud/unify-commands-and-service-options

unify configuration and commands
This commit is contained in:
Willy Kloucek
2022-01-07 13:49:23 +01:00
committed by GitHub
307 changed files with 5365 additions and 5131 deletions

View File

@@ -22,7 +22,7 @@ import (
func AppProvider(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "app-provider",
Usage: "Start appprovider for providing apps",
Usage: "start appprovider for providing apps",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage-app-provider")
},

View File

@@ -23,7 +23,7 @@ import (
func AuthBasic(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "auth-basic",
Usage: "Start authprovider for basic auth",
Usage: "start authprovider for basic auth",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage-auth-basic")
},

View File

@@ -22,7 +22,7 @@ import (
func AuthBearer(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "auth-bearer",
Usage: "Start authprovider for bearer auth",
Usage: "start authprovider for bearer auth",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage-auth-bearer")
},

View File

@@ -22,7 +22,7 @@ import (
func AuthMachine(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "auth-machine",
Usage: "Start authprovider for machine auth",
Usage: "start authprovider for machine auth",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage-auth-machine")
},

View File

@@ -26,7 +26,7 @@ import (
func Frontend(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "frontend",
Usage: "Start frontend service",
Usage: "start frontend service",
Before: func(c *cli.Context) error {
if err := loadUserAgent(c, cfg); err != nil {
return err

View File

@@ -30,7 +30,7 @@ import (
func Gateway(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "gateway",
Usage: "Start gateway",
Usage: "start gateway",
Before: func(c *cli.Context) error {
if err := ParseConfig(c, cfg, "storage-gateway"); err != nil {
return err

View File

@@ -23,7 +23,7 @@ import (
func Groups(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "groups",
Usage: "Start groups service",
Usage: "start groups service",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage-groups")
},

View File

@@ -11,8 +11,9 @@ import (
// Health is the entrypoint for the health command.
func Health(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "health",
Usage: "Check health status",
Name: "health",
Usage: "check health status",
Category: "info",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage")
},
@@ -34,7 +35,7 @@ func Health(cfg *config.Config) *cli.Command {
defer resp.Body.Close()
if resp.StatusCode != 200 {
if resp.StatusCode != http.StatusOK {
logger.Fatal().
Int("code", resp.StatusCode).
Msg("Health seems to be in bad state")

View File

@@ -3,57 +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),
StorageHome(cfg),
StorageUsers(cfg),
StoragePublicLink(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),
Sharing(cfg),
StorageHome(cfg),
StorageUsers(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

@@ -25,7 +25,7 @@ import (
func Sharing(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "sharing",
Usage: "Start sharing service",
Usage: "start sharing service",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage-sharing")
},

View File

@@ -24,7 +24,7 @@ import (
func StorageHome(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "storage-home",
Usage: "Start storage-home service",
Usage: "start storage-home service",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage-home")
},

View File

@@ -28,11 +28,11 @@ import (
func StorageMetadata(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "storage-metadata",
Usage: "Start storage-metadata service",
Usage: "start storage-metadata service",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage-metadata")
},
Category: "Extensions",
Category: "extensions",
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
tracing.Configure(cfg, logger)

View File

@@ -22,11 +22,11 @@ import (
func StoragePublicLink(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "storage-public-link",
Usage: "Start storage-public-link service",
Usage: "start storage-public-link service",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage-public-link")
},
Category: "Extensions",
Category: "extensions",
Action: func(c *cli.Context) error {
logger := NewLogger(cfg)
tracing.Configure(cfg, logger)

View File

@@ -23,7 +23,7 @@ import (
func StorageUsers(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "storage-users",
Usage: "Start storage-users service",
Usage: "start storage-users service",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage-userprovider")
},

View File

@@ -23,7 +23,7 @@ import (
func Users(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "users",
Usage: "Start users service",
Usage: "start users service",
Before: func(c *cli.Context) error {
return ParseConfig(c, cfg, "storage-users")
},