MCPcopy
hub / github.com/opencloud-eu/opencloud / Version

Function Version

services/users/pkg/command/version.go:17–49  ·  view source on GitHub ↗

Version prints the service versions of all running instances.

(cfg *config.Config)

Source from the content-addressed store, hash-verified

15
16// Version prints the service versions of all running instances.
17func Version(cfg *config.Config) *cobra.Command {
18 return &cobra.Command{
19 Use: "version",
20 Short: "print the version of this binary and the running service instances",
21 RunE: func(cmd *cobra.Command, args []string) error {
22 fmt.Println("Version: " + version.GetString())
23 fmt.Printf("Compiled: %s\n", version.Compiled())
24 fmt.Println("")
25
26 reg := registry.GetRegistry()
27 services, err := reg.GetService(cfg.GRPC.Namespace + "." + cfg.Service.Name)
28 if err != nil {
29 fmt.Println(fmt.Errorf("could not get %s services from the registry: %v", cfg.Service.Name, err))
30 return err
31 }
32
33 if len(services) == 0 {
34 fmt.Println("No running " + cfg.Service.Name + " service found.")
35 return nil
36 }
37
38 table := tablewriter.NewTable(os.Stdout, tablewriter.WithHeaderAutoFormat(tw.Off))
39 table.Header([]string{"Version", "Address", "Id"})
40 for _, s := range services {
41 for _, n := range s.Nodes {
42 table.Append([]string{s.Version, n.Address, n.Id})
43 }
44 }
45 table.Render()
46 return nil
47 },
48 }
49}

Callers 1

GetCommandsFunction · 0.70

Calls 6

GetStringFunction · 0.92
CompiledFunction · 0.92
GetRegistryFunction · 0.92
GetServiceMethod · 0.80
ErrorfMethod · 0.80
RenderMethod · 0.45

Tested by

no test coverage detected