| 1 | /* |
| 2 | Copyright 2025 The Kubernetes Authors. |
| 3 | |
| 4 | Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | you may not use this file except in compliance with the License. |
| 6 | You may obtain a copy of the License at |
| 7 | |
| 8 | http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | |
| 10 | Unless required by applicable law or agreed to in writing, software |
| 11 | distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | See the License for the specific language governing permissions and |
| 14 | limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package helpersscip-go gomod sigs.k8s.io/release-utils . `sigs.k8s.io/release-utils/helpers`/ |
| 18 | |
| 19 | import ( |
| 20 | "ioscip-go gomod github.com/golang/go/src go1.24.0 io/" |
| 21 | |
| 22 | "github.com/olekukonko/tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/" |
| 23 | "github.com/olekukonko/tablewriter/rendererscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/renderer`/" |
| 24 | "github.com/olekukonko/tablewriter/twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/" |
| 25 | ) |
| 26 | |
| 27 | // NewTableWriter creates a new table writer with the given output and options. |
| 28 | func NewTableWriterscip-go gomod sigs.k8s.io/release-utils . `sigs.k8s.io/release-utils/helpers`/NewTableWriter().(output ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, options ...tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.Optionscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/Option#) *tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.Tablescip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/Table# { |
| 29 | table := tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.NewWriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/NewWriter().(output) |
| 30 | for _, opt := range options { |
| 31 | table.Optionsscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/Table#Options().(opt) |
| 32 | } |
| 33 | |
| 34 | return table |
| 35 | } |
| 36 | |
| 37 | // NewTableWriterWithDefaults creates a new table writer with default markdown configuration. |
| 38 | // It includes left alignment, markdown renderer, and custom borders optimized for terminal output. |
| 39 | func NewTableWriterWithDefaultsscip-go gomod sigs.k8s.io/release-utils . `sigs.k8s.io/release-utils/helpers`/NewTableWriterWithDefaults().(output ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, options ...tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.Optionscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/Option#) *tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.Tablescip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/Table# { |
| 40 | defaultOptions := []tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.Optionscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/Option#{ |
| 41 | tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.WithConfigscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/WithConfig().(tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.Configscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/Config#{ |
| 42 | Headerscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/Config#Header.: twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.CellConfigscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/CellConfig#{ |
| 43 | Alignmentscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/CellConfig#Alignment.: twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.CellAlignmentscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/CellAlignment#{Globalscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/CellAlignment#Global.: twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.AlignLeftscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/AlignLeft.}, |
| 44 | }, |
| 45 | }), |
| 46 | tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.WithRendererscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/WithRenderer().(rendererscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/renderer`/.NewMarkdownscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/renderer`/NewMarkdown().()), |
| 47 | tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.WithRenditionscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/WithRendition().(twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.Renditionscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Rendition#{ |
| 48 | Symbolsscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Rendition#Symbols.: twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.NewSymbolsscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/NewSymbols().(twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.StyleMarkdownscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/StyleMarkdown.), |
| 49 | Bordersscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Rendition#Borders.: twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.Borderscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Border#{ |
| 50 | Leftscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Border#Left.: twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.Onscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/On., |
| 51 | Topscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Border#Top.: twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.Offscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Off., |
| 52 | Rightscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Border#Right.: twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.Onscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/On., |
| 53 | Bottomscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Border#Bottom.: twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.Offscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Off., |
| 54 | }, |
| 55 | Settingsscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Rendition#Settings.: twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.Settingsscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Settings#{ |
| 56 | Separatorsscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Settings#Separators.: twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.Separatorsscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Separators#{ |
| 57 | BetweenRowsscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/Separators#BetweenRows.: twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.Onscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/On., |
| 58 | }, |
| 59 | }, |
| 60 | }), |
| 61 | tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.WithRowAutoWrapscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/WithRowAutoWrap().(twscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/.WrapNonescip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter/tw`/WrapNone.), |
| 62 | } |
| 63 | |
| 64 | defaultOptions = append(defaultOptions, options...) |
| 65 | |
| 66 | return NewTableWriterscip-go gomod sigs.k8s.io/release-utils . `sigs.k8s.io/release-utils/helpers`/NewTableWriter().(output, defaultOptions...) |
| 67 | } |
| 68 | |
| 69 | // NewTableWriterWithDefaultsAndHeader creates a new table writer with default configuration and header. |
| 70 | func NewTableWriterWithDefaultsAndHeaderscip-go gomod sigs.k8s.io/release-utils . `sigs.k8s.io/release-utils/helpers`/NewTableWriterWithDefaultsAndHeader().(output ioscip-go gomod github.com/golang/go/src go1.24.0 io/.Writerscip-go gomod github.com/golang/go/src go1.24.0 io/Writer#, header []string, options ...tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.Optionscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/Option#) *tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.Tablescip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/Table# { |
| 71 | headerOption := tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.WithHeaderscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/WithHeader().(header) |
| 72 | allOptions := append([]tablewriterscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/.Optionscip-go gomod github.com/olekukonko/tablewriter v1.1.0 `github.com/olekukonko/tablewriter`/Option#{headerOption}, options...) |
| 73 | |
| 74 | return NewTableWriterWithDefaultsscip-go gomod sigs.k8s.io/release-utils . `sigs.k8s.io/release-utils/helpers`/NewTableWriterWithDefaults().(output, allOptions...) |
| 75 | } |