Skip to content

Instantly share code, notes, and snippets.

@richardcase
Created March 23, 2021 06:02
Show Gist options
  • Save richardcase/f708a60d1d9ef097efe6a9d4544ebd55 to your computer and use it in GitHub Desktop.
Save richardcase/f708a60d1d9ef097efe6a9d4544ebd55 to your computer and use it in GitHub Desktop.
Table Printer - example
func (p *tableObjectPrinter) Print(in interface{}, writer io.Writer) error {
inObj, ok := in.(*metav1.Table)
if !ok {
return ErrTableRequired
}
options := cliprint.PrintOptions{}
tablePrinter := cliprint.NewTablePrinter(options)
scheme, _, _ := historyv1alpha.NewSchemeAndCodecs()
printer, err := cliprint.NewTypeSetter(scheme).WrapToPrinter(tablePrinter, nil)
if err != nil {
return err
}
return printer.PrintObj(inObj, writer)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment