diff --git a/go.mod b/go.mod index 44e29c9160..f92b5c5366 100644 --- a/go.mod +++ b/go.mod @@ -8,7 +8,7 @@ require ( github.com/go-logr/logr v1.4.3 github.com/golang-jwt/jwt/v4 v4.5.2 github.com/google/go-containerregistry v0.21.3 - github.com/jedib0t/go-pretty/v6 v6.7.8 + github.com/jedib0t/go-pretty/v6 v6.7.9 github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 github.com/onsi/ginkgo/v2 v2.28.1 github.com/onsi/gomega v1.39.1 diff --git a/go.sum b/go.sum index a88e5e8c54..d4124365d8 100644 --- a/go.sum +++ b/go.sum @@ -282,8 +282,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.7.8 h1:BVYrDy5DPBA3Qn9ICT+PokP9cvCv1KaHv2i+Hc8sr5o= -github.com/jedib0t/go-pretty/v6 v6.7.8/go.mod h1:YwC5CE4fJ1HFUDeivSV1r//AmANFHyqczZk+U6BDALU= +github.com/jedib0t/go-pretty/v6 v6.7.9 h1:frarzQWmkZd97syT81+TH8INKPpzoxQnk+Mk5EIHSrM= +github.com/jedib0t/go-pretty/v6 v6.7.9/go.mod h1:YwC5CE4fJ1HFUDeivSV1r//AmANFHyqczZk+U6BDALU= github.com/joshdk/go-junit v1.0.0 h1:S86cUKIdwBHWwA6xCmFlf3RTLfVXYQfvanM5Uh+K6GE= github.com/joshdk/go-junit v1.0.0/go.mod h1:TiiV0PqkaNfFXjEiyjWM3XXrhVyCa1K4Zfga6W52ung= github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/render_markdown.go b/vendor/github.com/jedib0t/go-pretty/v6/table/render_markdown.go index ff298b1fdd..d7227d363d 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/table/render_markdown.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/render_markdown.go @@ -51,22 +51,49 @@ func (t *Table) markdownRenderRow(out *strings.Builder, row rowStr, hint renderH if colIdx < len(row) { colStr = row[colIdx] } - out.WriteRune(' ') colStr = strings.ReplaceAll(colStr, "|", "\\|") colStr = strings.ReplaceAll(colStr, "\n", "
") - out.WriteString(colStr) - out.WriteRune(' ') + if t.style.Markdown.PadContent { + out.WriteRune(' ') + align := t.getAlign(colIdx, hint) + out.WriteString(align.Apply(colStr, t.maxColumnLengths[colIdx])) + out.WriteRune(' ') + } else { + out.WriteRune(' ') + out.WriteString(colStr) + out.WriteRune(' ') + } out.WriteRune('|') } } func (t *Table) markdownRenderRowAutoIndex(out *strings.Builder, colIdx int, hint renderHint) { if colIdx == 0 && t.autoIndex { - out.WriteRune(' ') if hint.isSeparatorRow { - out.WriteString("---:") + if t.style.Markdown.PadContent { + out.WriteString(" " + strings.Repeat("-", t.autoIndexVIndexMaxLength) + ":") + } else { + out.WriteRune(' ') + out.WriteString("---:") + } } else if hint.isRegularRow() { - fmt.Fprintf(out, "%d ", hint.rowNumber) + if t.style.Markdown.PadContent { + rowNumStr := fmt.Sprint(hint.rowNumber) + out.WriteRune(' ') + fmt.Fprintf(out, "%*s", t.autoIndexVIndexMaxLength, rowNumStr) + out.WriteRune(' ') + } else { + out.WriteRune(' ') + fmt.Fprintf(out, "%d ", hint.rowNumber) + } + } else { + if t.style.Markdown.PadContent { + out.WriteRune(' ') + out.WriteString(strings.Repeat(" ", t.autoIndexVIndexMaxLength)) + out.WriteRune(' ') + } else { + out.WriteRune(' ') + } } out.WriteRune('|') } @@ -107,7 +134,12 @@ func (t *Table) markdownRenderSeparator(out *strings.Builder, hint renderHint) { for colIdx := 0; colIdx < t.numColumns; colIdx++ { t.markdownRenderRowAutoIndex(out, colIdx, hint) - out.WriteString(t.getAlign(colIdx, hint).MarkdownProperty()) + align := t.getAlign(colIdx, hint) + if t.style.Markdown.PadContent { + out.WriteString(align.MarkdownProperty(t.maxColumnLengths[colIdx])) + } else { + out.WriteString(align.MarkdownProperty()) + } out.WriteRune('|') } } diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/style.go b/vendor/github.com/jedib0t/go-pretty/v6/table/style.go index b5f5849346..0b2473de02 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/table/style.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/style.go @@ -3,14 +3,15 @@ package table // Style declares how to render the Table and provides very fine-grained control // on how the Table gets rendered on the Console. type Style struct { - Name string // name of the Style - Box BoxStyle // characters to use for the boxes - Color ColorOptions // colors to use for the rows and columns - Format FormatOptions // formatting options for the rows and columns - HTML HTMLOptions // rendering options for HTML mode - Options Options // misc. options for the table - Size SizeOptions // size (width) options for the table - Title TitleOptions // formation options for the title text + Name string // name of the Style + Box BoxStyle // characters to use for the boxes + Color ColorOptions // colors to use for the rows and columns + Format FormatOptions // formatting options for the rows and columns + HTML HTMLOptions // rendering options for HTML mode + Markdown MarkdownOptions // rendering options for Markdown mode + Options Options // misc. options for the table + Size SizeOptions // size (width) options for the table + Title TitleOptions // formation options for the title text } var ( diff --git a/vendor/github.com/jedib0t/go-pretty/v6/table/style_markdown.go b/vendor/github.com/jedib0t/go-pretty/v6/table/style_markdown.go new file mode 100644 index 0000000000..a4c6632c31 --- /dev/null +++ b/vendor/github.com/jedib0t/go-pretty/v6/table/style_markdown.go @@ -0,0 +1,25 @@ +package table + +// MarkdownOptions defines options to control Markdown rendering. +type MarkdownOptions struct { + // PadContent pads each column content to match the longest content in + // the column, and extends the separator dashes to match. This makes the + // raw Markdown source more readable without affecting the rendered + // output. + // + // When disabled (default): + // | # | First Name | Last Name | Salary | | + // | ---:| --- | --- | ---:| --- | + // | 1 | Arya | Stark | 3000 | | + // + // When enabled: + // | # | First Name | Last Name | Salary | | + // | ---:| ---------- | --------- | ------:| --------------------------- | + // | 1 | Arya | Stark | 3000 | | + PadContent bool +} + +var ( + // DefaultMarkdownOptions defines sensible Markdown rendering defaults. + DefaultMarkdownOptions = MarkdownOptions{} +) diff --git a/vendor/github.com/jedib0t/go-pretty/v6/text/align.go b/vendor/github.com/jedib0t/go-pretty/v6/text/align.go index 189531dc69..33512ee89d 100644 --- a/vendor/github.com/jedib0t/go-pretty/v6/text/align.go +++ b/vendor/github.com/jedib0t/go-pretty/v6/text/align.go @@ -76,16 +76,24 @@ func (a Align) HTMLProperty() string { } // MarkdownProperty returns the equivalent Markdown horizontal-align separator. -func (a Align) MarkdownProperty() string { +// An optional minLength can be provided to extend the dashes to match the +// column content width; the result will be max(minLength, 3)+2 wide (including +// leading/trailing space or colon). Without minLength (or 0), it defaults to 3. +func (a Align) MarkdownProperty(minLength ...int) string { + length := 3 + if len(minLength) > 0 && minLength[0] > length { + length = minLength[0] + } + dashes := strings.Repeat("-", length) switch a { case AlignLeft: - return ":--- " + return ":" + dashes + " " case AlignCenter: - return ":---:" + return ":" + dashes + ":" case AlignRight: - return " ---:" + return " " + dashes + ":" default: - return " --- " + return " " + dashes + " " } } diff --git a/vendor/modules.txt b/vendor/modules.txt index 99cfd3d5a3..e6ad1313b8 100644 --- a/vendor/modules.txt +++ b/vendor/modules.txt @@ -349,7 +349,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.7.8 +# github.com/jedib0t/go-pretty/v6 v6.7.9 ## explicit; go 1.18 github.com/jedib0t/go-pretty/v6/table github.com/jedib0t/go-pretty/v6/text