mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-13 22:05:59 +00:00
Add printer#EnsurePrintHeaders method
This patch adds a new `EnsurePrintHeaders` method to the HumanReadablePrinter `ResourcePrinter`, which allows headers to be printed in cases where multiple lists of the same resource are printed consecutively, but are separated by non-printer related information.
This commit is contained in:
parent
4520819df7
commit
78ccf2dd52
@ -419,6 +419,15 @@ func (h *HumanReadablePrinter) EnsurePrintWithKind(kind string) {
|
|||||||
h.options.Kind = kind
|
h.options.Kind = kind
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// EnsurePrintHeaders sets the HumanReadablePrinter option "NoHeaders" to false
|
||||||
|
// and removes the .lastType that was printed, which forces headers to be
|
||||||
|
// printed in cases where multiple lists of the same resource are printed
|
||||||
|
// consecutively, but are separated by non-printer related information.
|
||||||
|
func (h *HumanReadablePrinter) EnsurePrintHeaders() {
|
||||||
|
h.options.NoHeaders = false
|
||||||
|
h.lastType = nil
|
||||||
|
}
|
||||||
|
|
||||||
// Handler adds a print handler with a given set of columns to HumanReadablePrinter instance.
|
// Handler adds a print handler with a given set of columns to HumanReadablePrinter instance.
|
||||||
// See validatePrintHandlerFunc for required method signature.
|
// See validatePrintHandlerFunc for required method signature.
|
||||||
func (h *HumanReadablePrinter) Handler(columns, columnsWithWide []string, printFunc interface{}) error {
|
func (h *HumanReadablePrinter) Handler(columns, columnsWithWide []string, printFunc interface{}) error {
|
||||||
|
Loading…
Reference in New Issue
Block a user