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

@@ -25,7 +25,6 @@ import (
"codeberg.org/scip/esctl/pkg/cfg"
"codeberg.org/scip/esctl/pkg/printer"
"github.com/dustin/go-humanize"
"github.com/elastic/go-elasticsearch/v9/typedapi/types"
)
@@ -73,13 +72,13 @@ func DatastreamList(conf *cfg.Config) error {
policy = *ds.IlmPolicy
}
table.Entries[idx] = []string{
table.Entries[idx] = []any{
name,
policy,
fmt.Sprintf("%t", ds.Hidden),
fmt.Sprintf("%t", *ds.System),
fmt.Sprintf("%t", *ds.Replicated),
fmt.Sprintf("%d", ds.Generation),
ds.Hidden,
*ds.System,
*ds.Replicated,
ds.Generation,
ds.TimestampField.Name,
}
@@ -156,18 +155,18 @@ func DatastreamShow(conf *cfg.Config, dsname string) error {
policy = *ds.IlmPolicy
}
table.Entries = [][]string{
table.Entries = [][]any{
{"name", name},
{"ilm policy", policy},
{"hidden", fmt.Sprintf("%t", ds.Hidden)},
{"system", fmt.Sprintf("%t", *ds.System)},
{"replicated", fmt.Sprintf("%t", *ds.Replicated)},
{"generation", fmt.Sprintf("%d", ds.Generation)},
{"hidden", ds.Hidden},
{"system", *ds.System},
{"replicated", *ds.Replicated},
{"generation", ds.Generation},
{"timestamp field", ds.TimestampField.Name},
{"backing indices", fmt.Sprintf("%d", stats.BackingIndices)},
{"size", humanize.Bytes(uint64(stats.TotalStoreSizeBytes))},
{"shards-failed", fmt.Sprintf("%d", stats.Shards_.Failed)},
{"shards-successful", fmt.Sprintf("%d", stats.Shards_.Successful)},
{"backing indices", stats.BackingIndices},
{"size", printer.Bytes(stats.TotalStoreSizeBytes)},
{"shards-failed", stats.Shards_.Failed},
{"shards-successful", stats.Shards_.Successful},
}
if err := table.Print(); err != nil {
@@ -183,10 +182,10 @@ func DatastreamShow(conf *cfg.Config, dsname string) error {
policy = *ds.IlmPolicy
}
table.Entries[idx] = []string{
table.Entries[idx] = []any{
index.IndexName,
index.IndexUuid,
fmt.Sprintf("%t", *index.PreferIlm),
*index.PreferIlm,
policy,
index.ManagedBy.Name,
}
@@ -235,10 +234,10 @@ func DatastreamRollover(conf *cfg.Config, ds string) error {
table := printer.NewTable(conf, 2, 5)
table.Addheaders("rollover response", "value")
table.Entries = [][]string{
{"acknowledged", fmt.Sprintf("%t", res.Acknowledged)},
{"rolled over", fmt.Sprintf("%t", res.RolledOver)},
{"shards acknowledged", fmt.Sprintf("%t", res.ShardsAcknowledged)},
table.Entries = [][]any{
{"acknowledged", res.Acknowledged},
{"rolled over", res.RolledOver},
{"shards acknowledged", res.ShardsAcknowledged},
{"old index", res.OldIndex},
{"new index", res.NewIndex},
}