mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-24 22:08:58 -05:00
* add policies service add policies proxy middleware add policies event service add policies grpc service prepare ci and git environments (ci, make, readme, doc) * add webfinger to the drone conf * fix docs remove not used virus scan postprocessing step * relocate example rego file implicitly enable and disable proxy and postprocessing policy checking by setting the query. update configuration descriptions * move policies update readme * use converter func to convert pp environment to actual environment expose and test custom rego functions add engine unit tests add opa unit tests update policies readme Co-authored-by: Martin <github@diemattels.at> * relocate sample policies to the deployments folder change and document policies service port * update index.md and small fix * add health command add version command add debug server --------- Co-authored-by: Martin <github@diemattels.at>
51 lines
1.3 KiB
Go
51 lines
1.3 KiB
Go
package command
|
|
|
|
import (
|
|
"fmt"
|
|
"os"
|
|
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
|
|
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
|
|
|
tw "github.com/olekukonko/tablewriter"
|
|
"github.com/owncloud/ocis/v2/services/policies/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 := 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
|
|
},
|
|
}
|
|
}
|