diff --git a/go.mod b/go.mod index 47a56d2a8..627808e7d 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/go-logr/logr v1.4.2 github.com/golang-jwt/jwt/v4 v4.5.1 github.com/google/go-containerregistry v0.20.2 - github.com/jedib0t/go-pretty/v6 v6.6.2 + github.com/jedib0t/go-pretty/v6 v6.6.3 github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 github.com/onsi/ginkgo/v2 v2.22.0 github.com/onsi/gomega v1.36.0 diff --git a/go.sum b/go.sum index 272f09c7b..00fe77ce6 100644 --- a/go.sum +++ b/go.sum @@ -245,8 +245,8 @@ github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2 github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLfsEA9PFc4w1p2J65bw= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 h1:BQSFePA1RWJOlocH6Fxy8MmwDt+yVQYULKfN0RoTN8A= github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99/go.mod h1:1lJo3i6rXxKeerYnT8Nvf0QmHCRC1n8sfWVwXF2Frvo= -github.com/jedib0t/go-pretty/v6 v6.6.2 h1:27bLj3nRODzaiA7tPIxy9UVWHoPspFfME9XxgwiiNsM= -github.com/jedib0t/go-pretty/v6 v6.6.2/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E= +github.com/jedib0t/go-pretty/v6 v6.6.3 h1:nGqgS0tgIO1Hto47HSaaK4ac/I/Bu7usmdD3qvs0WvM= +github.com/jedib0t/go-pretty/v6 v6.6.3/go.mod h1:zbn98qrYlh95FIhwwsbIip0LYpwSG8SUOScs+v9/t0E= github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/table.go b/vendor/github.com/jedib0t/go-pretty/v6/table/table.go index 35426c5ca..6cf043308 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/table/table.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/table.go @@ -186,6 +186,25 @@ func (t *Table) AppendSeparator() { } } +// ImportGrid helps import 1d or 2d arrays as rows. +func (t *Table) ImportGrid(grid interface{}) bool { + rows := objAsSlice(grid) + if rows == nil { + return false + } + addedRows := false + for _, row := range rows { + rowAsSlice := objAsSlice(row) + if rowAsSlice != nil { + t.AppendRow(rowAsSlice) + } else if row != nil { + t.AppendRow(Row{row}) + } + addedRows = true + } + return addedRows +} + // Length returns the number of rows to be rendered. func (t *Table) Length() int { return len(t.rowsRaw) diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/util.go b/vendor/github.com/jedib0t/go-pretty/v6/table/util.go index aa710125e..6b7a6585d 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/table/util.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/util.go @@ -67,3 +67,46 @@ func (m mergedColumnIndices) safeAppend(colIdx, otherColIdx int) { } m[otherColIdx][colIdx] = true } + +func objAsSlice(in interface{}) []interface{} { + var out []interface{} + if in != nil { + // dereference pointers + val := reflect.ValueOf(in) + if val.Kind() == reflect.Ptr && !val.IsNil() { + in = val.Elem().Interface() + } + + if objIsSlice(in) { + v := reflect.ValueOf(in) + for i := 0; i < v.Len(); i++ { + // dereference pointers + v2 := v.Index(i) + if v2.Kind() == reflect.Ptr && !v2.IsNil() { + v2 = reflect.ValueOf(v2.Elem().Interface()) + } + + out = append(out, v2.Interface()) + } + } + } + + // remove trailing nil pointers + tailIdx := len(out) + for i := len(out) - 1; i >= 0; i-- { + val := reflect.ValueOf(out[i]) + if val.Kind() != reflect.Ptr || !val.IsNil() { + break + } + tailIdx = i + } + return out[:tailIdx] +} + +func objIsSlice(in interface{}) bool { + if in == nil { + return false + } + k := reflect.TypeOf(in).Kind() + return k == reflect.Slice || k == reflect.Array +} diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/writer.go b/vendor/github.com/jedib0t/go-pretty/v6/table/writer.go index ec7a53a7e..406aaab43 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/table/writer.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/writer.go @@ -11,6 +11,7 @@ type Writer interface { AppendRow(row Row, configs ...RowConfig) AppendRows(rows []Row, configs ...RowConfig) AppendSeparator() + ImportGrid(grid interface{}) bool Length() int Pager(opts ...PagerOption) Pager Render() string diff --git a/vendor/modules.txt b/vendor/modules.txt index 2322706b8..2e6bbe1bf 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -313,7 +313,7 @@ github.com/inconshreveable/mousetrap # github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 ## explicit github.com/jbenet/go-context/io -# github.com/jedib0t/go-pretty/v6 v6.6.2 +# github.com/jedib0t/go-pretty/v6 v6.6.3 ## explicit; go 1.17 github.com/jedib0t/go-pretty/v6/table github.com/jedib0t/go-pretty/v6/text