Created
March 23, 2021 06:02
-
-
Save richardcase/f708a60d1d9ef097efe6a9d4544ebd55 to your computer and use it in GitHub Desktop.
Table Printer - example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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