conversion from string cells to any cells in printer.Table

This commit is contained in:
2026-07-07 06:30:07 +02:00
parent 033dd0ccd1
commit 2d8ecae73b
19 changed files with 135 additions and 157 deletions

View File

@@ -20,7 +20,6 @@ import (
"context"
"fmt"
"log/slog"
"strings"
"codeberg.org/scip/esctl/pkg/cfg"
"codeberg.org/scip/esctl/pkg/printer"
@@ -58,10 +57,10 @@ func RoleList(conf *cfg.Config) error {
idx := 0
for name, role := range res {
table.Entries[idx] = []string{
table.Entries[idx] = []any{
name,
fmt.Sprintf("%d", len(role.Cluster)),
fmt.Sprintf("%d", len(role.Indices)),
role.Cluster,
role.Indices,
}
idx++
}
@@ -140,10 +139,8 @@ func roleRemoteClusters(conf *cfg.Config, role types.Role) error {
perms = append(perms, perm.Name)
}
table.Entries[idx] = []string{
strings.Join(priv.Clusters, ","),
strings.Join(perms, ","),
}
table.Entries[idx] = []any{priv.Clusters, perms}
idx++
}
@@ -160,7 +157,7 @@ func roleClusters(conf *cfg.Config, role types.Role) error {
table.Addheaders("cluster rights")
idx := 0
for _, cluster := range role.Cluster {
table.Entries[idx] = []string{cluster.Name}
table.Entries[idx] = []any{cluster.Name}
idx++
}
@@ -182,11 +179,7 @@ func roleRemoteIndices(conf *cfg.Config, role types.Role) error {
perms = append(perms, perm.Name)
}
table.Entries[idx] = []string{
strings.Join(priv.Names, ", "),
strings.Join(perms, ", "),
fmt.Sprintf("%t", *priv.AllowRestrictedIndices),
}
table.Entries[idx] = []any{priv.Names, perms, *priv.AllowRestrictedIndices}
idx++
}
@@ -209,11 +202,7 @@ func roleIndices(conf *cfg.Config, role types.Role) error {
perms = append(perms, perm.Name)
}
table.Entries[idx] = []string{
strings.Join(priv.Names, ", "),
strings.Join(perms, ", "),
fmt.Sprintf("%t", *priv.AllowRestrictedIndices),
}
table.Entries[idx] = []any{priv.Names, perms, *priv.AllowRestrictedIndices}
idx++
}
@@ -231,10 +220,10 @@ func roleApplications(conf *cfg.Config, role types.Role) error {
table.Addheaders("application", "privileges", "resources")
idx := 0
for _, priv := range role.Applications {
table.Entries[idx] = []string{
table.Entries[idx] = []any{
priv.Application,
strings.Join(priv.Privileges, ", "),
strings.Join(priv.Resources, ", "),
priv.Privileges,
priv.Resources,
}
idx++