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

@@ -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
}