mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 12:19:37 -06:00
add missing commands and unify service / namespace options
This commit is contained in:
@@ -26,7 +26,7 @@ func Execute(cfg *config.Config) error {
|
||||
},
|
||||
},
|
||||
Before: func(c *cli.Context) error {
|
||||
cfg.Server.Version = version.String
|
||||
cfg.Service.Version = version.String
|
||||
return ParseConfig(c, cfg)
|
||||
},
|
||||
Commands: []*cli.Command{
|
||||
|
||||
@@ -42,7 +42,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
|
||||
defer cancel()
|
||||
|
||||
mtrcs.BuildInfo.WithLabelValues(cfg.Server.Version).Set(1)
|
||||
mtrcs.BuildInfo.WithLabelValues(cfg.Service.Version).Set(1)
|
||||
|
||||
{
|
||||
server, err := http.Server(
|
||||
|
||||
47
graph-explorer/pkg/command/version.go
Normal file
47
graph-explorer/pkg/command/version.go
Normal file
@@ -0,0 +1,47 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/registry"
|
||||
|
||||
tw "github.com/olekukonko/tablewriter"
|
||||
"github.com/owncloud/ocis/graph-explorer/pkg/config"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
// PrintVersion prints the service versions of all running instances.
|
||||
func PrintVersion(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 {
|
||||
reg := registry.GetRegistry()
|
||||
services, err := reg.GetService(cfg.HTTP.Namespace + "." + cfg.Service.Name)
|
||||
if err != nil {
|
||||
fmt.Println(fmt.Errorf("could not get graph services from the registry: %v", err))
|
||||
return err
|
||||
}
|
||||
|
||||
if len(services) == 0 {
|
||||
fmt.Println("No running graph service found.")
|
||||
return nil
|
||||
}
|
||||
|
||||
table := tw.NewWriter(os.Stdout)
|
||||
table.SetHeader([]string{"Version", "Address", "Id"})
|
||||
table.SetAutoFormatHeaders(false)
|
||||
for _, s := range services {
|
||||
for _, n := range s.Nodes {
|
||||
table.Append([]string{s.Version, n.Address, n.Id})
|
||||
}
|
||||
}
|
||||
table.Render()
|
||||
return nil
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -21,10 +21,10 @@ type HTTP struct {
|
||||
Namespace string `ocisConfig:"namespace"`
|
||||
}
|
||||
|
||||
// Server configures a server.
|
||||
type Server struct {
|
||||
Version string `ocisConfig:"version"`
|
||||
// Service defines the available service configuration.
|
||||
type Service struct {
|
||||
Name string `ocisConfig:"name"`
|
||||
Version string `ocisConfig:"version"`
|
||||
}
|
||||
|
||||
// Tracing defines the available tracing configuration.
|
||||
@@ -50,7 +50,7 @@ type Config struct {
|
||||
Log shared.Log `ocisConfig:"log"`
|
||||
Debug Debug `ocisConfig:"debug"`
|
||||
HTTP HTTP `ocisConfig:"http"`
|
||||
Server Server `ocisConfig:"server"`
|
||||
Service Service `ocisConfig:"service"`
|
||||
Tracing Tracing `ocisConfig:"tracing"`
|
||||
GraphExplorer GraphExplorer `ocisConfig:"graph_explorer"`
|
||||
|
||||
@@ -78,7 +78,9 @@ func DefaultConfig() *Config {
|
||||
Root: "/graph-explorer",
|
||||
Namespace: "com.owncloud.web",
|
||||
},
|
||||
Server: Server{},
|
||||
Service: Service{
|
||||
Name: "graph",
|
||||
},
|
||||
Tracing: Tracing{
|
||||
Type: "jaeger",
|
||||
Endpoint: "",
|
||||
|
||||
Reference in New Issue
Block a user