mirror of
https://github.com/owncloud/ocis
synced 2026-04-25 17:25:21 +02:00
* chore(deps): bump github.com/olekukonko/tablewriter from 0.0.5 to 1.0.9 Bumps [github.com/olekukonko/tablewriter](https://github.com/olekukonko/tablewriter) from 0.0.5 to 1.0.9. - [Commits](https://github.com/olekukonko/tablewriter/compare/v0.0.5...v1.0.9) --- updated-dependencies: - dependency-name: github.com/olekukonko/tablewriter dependency-version: 1.0.9 dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * fix: adjust to tablewriter 1.0.9 (AI-powered) Signed-off-by: Julian Koberg <julian.koberg@kiteworks.com> * update to NewTable * bring back a Footer * fix the tests --------- Signed-off-by: dependabot[bot] <support@github.com> Signed-off-by: Julian Koberg <julian.koberg@kiteworks.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Julian Koberg <julian.koberg@kiteworks.com> Co-authored-by: Roman Perekhod <rperekhod@owncloud.com>
50 lines
1.3 KiB
Go
50 lines
1.3 KiB
Go
package command
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/olekukonko/tablewriter"
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
|
|
|
"github.com/owncloud/ocis/v2/services/storage-publiclink/pkg/config"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// Version prints the service versions of all running instances.
|
|
func Version(cfg *config.Config) *cli.Command {
|
|
return &cli.Command{
|
|
Name: "version",
|
|
Usage: "print the version of this binary and the running service instances",
|
|
Category: "info",
|
|
Action: func(c *cli.Context) error {
|
|
fmt.Println("Version: " + version.GetString())
|
|
fmt.Printf("Compiled: %s\n", version.Compiled())
|
|
fmt.Println("")
|
|
|
|
reg := registry.GetRegistry()
|
|
services, err := reg.GetService(cfg.GRPC.Namespace + "." + cfg.Service.Name)
|
|
if err != nil {
|
|
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 " + cfg.Service.Name + " service found.")
|
|
return nil
|
|
}
|
|
|
|
table := tablewriter.NewTable(os.Stdout)
|
|
table.Header("Version", "Address", "Id")
|
|
for _, s := range services {
|
|
for _, n := range s.Nodes {
|
|
table.Append([]string{s.Version, n.Address, n.Id})
|
|
}
|
|
}
|
|
table.Render()
|
|
return nil
|
|
},
|
|
}
|
|
}
|