Update kubectl.GetPrinter to not return both nil for the printer and nil for the error on wide
format
#38779
Labels
area/kubectl
help wanted
Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines.
sig/cli
Categorizes an issue or PR as relevant to SIG CLI.
Problem
Right now, printer helpers such as cmdutil.PrinterForCommand call kubectl.GetPrinter with the output format specified by a
--output
flag, in order to retrieve the right printer for that format.When
kubect.GetPrinter
is called with awide
format, nil is returned for both the printer and the error. This has inevitably led to panics throughout kubectl commands whenever code that callskubectl.GetPrinter
(either directly or indirectly through cmdutil.PrinterForCommand`) attempts to use the retrieved printer if no errors are returned. For example:Commands like
kubectl create
andkubectl apply
get around this by only supporting thename
output format, however when expanding these commands to eventually use all supported output formats by resource printers (json, yaml, custom-columns, etc...), this becomes an issue.Proposal
nil
NewHumanReadablePrinter
with the rightPrintOptions
for example,NewHumanReadablePrinter
inkubectl.GetPrinter
any time the output format specified ==wide
.cc @fabianofranz @pwittrock @adohe @deads2k
The text was updated successfully, but these errors were encountered: