refactor oc runtime server from urfave/cli to spf13/cobra

Signed-off-by: Christian Richter <c.richter@opencloud.eu>
This commit is contained in:
Christian Richter
2025-12-03 15:12:32 +01:00
committed by Florian Schade
parent 67981d8f9a
commit 07c160f67c

View File

@@ -6,22 +6,22 @@ import (
"github.com/opencloud-eu/opencloud/pkg/config" "github.com/opencloud-eu/opencloud/pkg/config"
"github.com/opencloud-eu/opencloud/pkg/config/configlog" "github.com/opencloud-eu/opencloud/pkg/config/configlog"
"github.com/opencloud-eu/opencloud/pkg/config/parser" "github.com/opencloud-eu/opencloud/pkg/config/parser"
"github.com/urfave/cli/v2"
"github.com/spf13/cobra"
) )
// Server is the entrypoint for the server command. // Server is the entrypoint for the server command.
func Server(cfg *config.Config) *cli.Command { func Server(cfg *config.Config) *cobra.Command {
return &cli.Command{ return &cobra.Command{
Name: "server", Use: "server",
Usage: "start a fullstack server (runtime and all services in supervised mode)", Short: "start a fullstack server (runtime and all services in supervised mode)",
Category: "fullstack", PreRunE: func(cmd *cobra.Command, args []string) error {
Before: func(c *cli.Context) error {
return configlog.ReturnError(parser.ParseConfig(cfg, false)) return configlog.ReturnError(parser.ParseConfig(cfg, false))
}, },
Action: func(c *cli.Context) error { RunE: func(cmd *cobra.Command, args []string) error {
// Prefer the in-memory registry as the default when running in single-binary mode // Prefer the in-memory registry as the default when running in single-binary mode
r := runtime.New(cfg) r := runtime.New(cfg)
return r.Start(c.Context) return r.Start(cmd.Context())
}, },
} }
} }