2020-09-18 12:49:16 +02:00
|
|
|
package command
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
"os"
|
2021-11-11 15:48:00 +01:00
|
|
|
|
2022-04-13 10:40:24 +02:00
|
|
|
"github.com/owncloud/ocis/extensions/storage/pkg/config"
|
2022-01-03 13:53:27 +01:00
|
|
|
"github.com/owncloud/ocis/ocis-pkg/clihelper"
|
2021-12-17 16:30:57 +01:00
|
|
|
"github.com/owncloud/ocis/ocis-pkg/log"
|
2021-09-14 16:05:03 +02:00
|
|
|
"github.com/urfave/cli/v2"
|
2020-09-18 12:49:16 +02:00
|
|
|
)
|
|
|
|
|
|
2022-01-03 13:53:27 +01:00
|
|
|
// 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),
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-10-05 20:39:29 +02:00
|
|
|
// Execute is the entry point for the storage command.
|
2021-03-03 17:36:03 +01:00
|
|
|
func Execute(cfg *config.Config) error {
|
2022-01-03 13:53:27 +01:00
|
|
|
app := clihelper.DefaultApp(&cli.App{
|
|
|
|
|
Name: "storage",
|
|
|
|
|
Usage: "Storage service for oCIS",
|
2020-09-18 12:49:16 +02:00
|
|
|
|
|
|
|
|
Before: func(c *cli.Context) error {
|
2021-12-17 16:30:57 +01:00
|
|
|
return ParseConfig(c, cfg, "storage")
|
2020-09-18 12:49:16 +02:00
|
|
|
},
|
|
|
|
|
|
2022-01-03 13:53:27 +01:00
|
|
|
Commands: GetCommands(cfg),
|
|
|
|
|
})
|
2020-09-18 12:49:16 +02:00
|
|
|
|
|
|
|
|
cli.HelpFlag = &cli.BoolFlag{
|
|
|
|
|
Name: "help,h",
|
|
|
|
|
Usage: "Show the help",
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return app.Run(os.Args)
|
|
|
|
|
}
|
2021-12-17 16:30:57 +01:00
|
|
|
|
|
|
|
|
// NewLogger initializes a service-specific logger instance.
|
|
|
|
|
func NewLogger(cfg *config.Config) log.Logger {
|
|
|
|
|
return log.NewLogger(
|
|
|
|
|
log.Name("storage"),
|
|
|
|
|
log.Level(cfg.Log.Level),
|
|
|
|
|
log.Pretty(cfg.Log.Pretty),
|
|
|
|
|
log.Color(cfg.Log.Color),
|
|
|
|
|
log.File(cfg.Log.File),
|
|
|
|
|
)
|
|
|
|
|
}
|