Denote if a printer is generic.

This fixes #38779.

This allows us to avoid case in which printers.GetStandardPrinter
returns nil for both printer and err removing any potential panics that
may arise throughout kubectl commands.

Please see #38779 and #38112 for complete context.

Add comment explaining adding handlers to printers.HumanReadablePrinter
also remove an unnecessary conversion of printers.HumanReadablePrinter
to printers.ResourcePrinter.
This commit is contained in:
Waseem Ahmad
2017-05-23 08:17:20 +05:30
parent 77a8c25839
commit 8442a118ea
24 changed files with 182 additions and 96 deletions

View File

@@ -80,8 +80,9 @@ func defaultClientConfigForVersion(version *schema.GroupVersion) *restclient.Con
}
type testPrinter struct {
Objects []runtime.Object
Err error
Objects []runtime.Object
Err error
GenericPrinter bool
}
func (t *testPrinter) PrintObj(obj runtime.Object, out io.Writer) error {
@@ -99,6 +100,10 @@ func (t *testPrinter) AfterPrint(output io.Writer, res string) error {
return nil
}
func (t *testPrinter) IsGeneric() bool {
return t.GenericPrinter
}
type testDescriber struct {
Name, Namespace string
Settings printers.DescriberSettings