refactor interims DefaultAppCobra to DefaultApp

Signed-off-by: Christian Richter <c.richter@opencloud.eu>
This commit is contained in:
Christian Richter
2025-12-03 15:08:01 +01:00
committed by Florian Schade
parent 6d054c527c
commit 7be33b0607
44 changed files with 46 additions and 67 deletions

View File

@@ -17,7 +17,7 @@ import (
func Execute() error {
cfg := config.DefaultConfig()
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "opencloud",
Short: "opencloud",
})

View File

@@ -4,33 +4,12 @@ import (
"fmt"
"github.com/opencloud-eu/opencloud/pkg/version"
"github.com/spf13/cobra"
"github.com/urfave/cli/v2"
)
// DefaultApp provides some default settings for the cli app
func DefaultApp(app *cli.App) *cli.App {
// version info
app.Version = version.String
app.Compiled = version.Compiled()
// author info
app.Authors = []*cli.Author{
{
Name: "OpenCloud GmbH",
Email: "support@opencloud.eu",
},
}
// disable global version flag
// instead we provide the version command
app.HideVersion = true
return app
}
// DefaultAppCobra is a wrapper for DefaultApp that adds Cobra specific settings
func DefaultAppCobra(app *cobra.Command) *cobra.Command {
// DefaultApp is a wrapper for DefaultApp that adds Cobra specific settings
func DefaultApp(app *cobra.Command) *cobra.Command {
// TODO: when migration is done this has to become DefaultApp
// version info
app.Version = fmt.Sprintf("%s (%s <%s>) (%s)", version.String, "OpenCloud GmbH", "support@opencloud.eu", version.Compiled())

View File

@@ -24,7 +24,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the activitylog command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "activitylog",
Short: "starts activitylog service",
})

View File

@@ -19,7 +19,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the antivirus command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "antivirus",
Short: "Antivirus service for OpenCloud",
})

View File

@@ -24,7 +24,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud app-provider command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "app-provider",
Short: "Provide apps for OpenCloud",
})

View File

@@ -24,7 +24,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud app-registry command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "app-registry",
Short: "Provide an app registry for OpenCloud",
})

View File

@@ -24,7 +24,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the audit command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "audit",
Short: "starts audit service",
})

View File

@@ -26,7 +26,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud auth-app command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "auth-app",
Short: "Provide app authentication for OpenCloud",
})

View File

@@ -24,7 +24,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud auth-basic command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "auth-basic",
Short: "Provide basic authentication for OpenCloud",
})

View File

@@ -28,7 +28,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud auth-bearer command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "auth-bearer",
Short: "Provide bearer authentication for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud auth-machine command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "auth-machine",
Short: "Provide machine authentication for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud auth-service command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "auth-service",
Short: "Provide service authentication for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the clientlog command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "clientlog",
Short: "starts clientlog service",
})

View File

@@ -20,7 +20,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the antivirus command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "collaboration",
Short: "Serve WOPI for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the eventhistory command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "eventhistory",
Short: "starts eventhistory service",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud-frontend command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "frontend",
Short: "Provide various HTTP apis for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud-gateway command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "gateway",
Short: "Provide a CS3api gateway for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud graph command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "graph",
Short: "Serve Graph API for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud group command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "group",
Short: "Provide groups for OpenCloud",
})

View File

@@ -26,7 +26,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud idm command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "idm",
Short: "Embedded LDAP service for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud-idp command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "idp",
Short: "Serve IDP API for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud invitations command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "invitations",
Short: "Serve invitations API for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the nats command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "nats",
Short: "starts nats server",
})

View File

@@ -26,7 +26,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the notifications command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "notifications",
Short: "starts notifications service",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the OpenCloud ocdav command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "ocdav",
Short: "Provide a WebDav API for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the ocm command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "ocm",
Short: "starts ocm service",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud-ocs command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "ocs",
Short: "Serve OCS API for OpenCloud",
})

View File

@@ -20,7 +20,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the policies command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "policies",
Short: "Serve policies for OpenCloud",
})

View File

@@ -26,7 +26,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the postprocessing command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "postprocessing",
Short: "starts postprocessing service",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud-proxy command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "proxy",
Short: "proxy for OpenCloud",
})

View File

@@ -26,7 +26,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud-search command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "search",
Short: "Serve search API for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud-settings command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "settings",
Short: "Provide settings and permissions for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the sharing command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "sharing",
Short: "Provide sharing for OpenCloud",
})

View File

@@ -20,7 +20,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the sse command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "sse",
Short: "Serve sse for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the storage-publiclink command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "storage-publiclink",
Short: "Provide publiclink storage for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the storage-shares command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "storage-shares",
Short: "Provide a virtual storage for shares in OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the storage-system command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "storage-system",
Short: "Provide system storage for OpenCloud",
})

View File

@@ -27,7 +27,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud-storage-users command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "storage-users",
Short: "Provide storage for users and projects in OpenCloud",
})

View File

@@ -24,7 +24,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud-thumbnails command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "thumbnails",
Short: "Example usage",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the userlog command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "userlog",
Short: "starts userlog service",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud-user command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "user",
Short: "Provide users for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the web command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "web",
Short: "Serve Web for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud-webdav command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "webdav",
Short: "Serve WebDAV API for OpenCloud",
})

View File

@@ -25,7 +25,7 @@ func GetCommands(cfg *config.Config) []*cobra.Command {
// Execute is the entry point for the opencloud webfinger command.
func Execute(cfg *config.Config) error {
app := clihelper.DefaultAppCobra(&cobra.Command{
app := clihelper.DefaultApp(&cobra.Command{
Use: "webfinger",
Short: "Serve webfinger API for OpenCloud",
})