Adjust to new tablewriter release

This commit is contained in:
Ralf Haferkamp
2025-05-19 19:26:38 +02:00
parent 70fc6eb40b
commit 96684df32d
36 changed files with 168 additions and 147 deletions

View File

@@ -6,6 +6,8 @@ import (
"strings"
"github.com/olekukonko/tablewriter"
"github.com/olekukonko/tablewriter/renderer"
"github.com/olekukonko/tablewriter/tw"
"github.com/urfave/cli/v2"
"github.com/opencloud-eu/opencloud/pkg/config/configlog"
@@ -54,12 +56,17 @@ func listUnifiedRoles(cfg *config.Config) *cli.Command {
Name: "list",
Usage: "list available unified roles",
Action: func(c *cli.Context) error {
tbl := tablewriter.NewWriter(os.Stdout)
tbl.SetRowLine(true)
tbl.SetAutoMergeCellsByColumnIndex([]int{0}) // rowspan should only affect the first column
r := tw.Rendition{
Settings: tw.Settings{
Separators: tw.Separators{
BetweenRows: tw.On,
},
},
}
tbl := tablewriter.NewTable(os.Stdout, tablewriter.WithRenderer(renderer.NewBlueprint(r)))
headers := []string{"Name", "UID", "Enabled", "Description", "Condition", "Allowed resource actions"}
tbl.SetHeader(headers)
tbl.Header(headers)
for _, definition := range unifiedrole.GetRoles(unifiedrole.RoleFilterAll()) {
const enabled = "enabled"

View File

@@ -7,7 +7,8 @@ import (
"github.com/opencloud-eu/opencloud/pkg/registry"
"github.com/opencloud-eu/opencloud/pkg/version"
tw "github.com/olekukonko/tablewriter"
"github.com/olekukonko/tablewriter"
"github.com/olekukonko/tablewriter/tw"
"github.com/opencloud-eu/opencloud/services/graph/pkg/config"
"github.com/urfave/cli/v2"
)
@@ -35,9 +36,8 @@ func Version(cfg *config.Config) *cli.Command {
return nil
}
table := tw.NewWriter(os.Stdout)
table.SetHeader([]string{"Version", "Address", "Id"})
table.SetAutoFormatHeaders(false)
table := tablewriter.NewTable(os.Stdout, tablewriter.WithHeaderAutoFormat(tw.Off))
table.Header([]string{"Version", "Address", "Id"})
for _, s := range services {
for _, n := range s.Nodes {
table.Append([]string{s.Version, n.Address, n.Id})