• Kubernetes Submit Queue's avatar
    Merge pull request #56629 from luksa/fix_custom_column_alignment · 9f4b851e
    Kubernetes Submit Queue authored
    Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions <a href="https://github.com/kubernetes/community/blob/master/contributors/devel/cherry-picks.md">here</a>.
    
    Fix bad column alignment when using custom columns from OpenAPI schema
    
    Columns printed by `kubectl get` weren't aligned properly when they were coming from the OpenAPI schema. 
    
    This was caused by `CustomColumnPrinter.PrintObj`, which was creating a new `tabwriter.Writer` instead of re-using the tabwriter received through the `out` method parameter (basically, a tabwriter was writing to another tabwriter). Because the PrintObj flushed the tabwriter after writing each individual line, the column widths would reset.
    
    **What this PR does / why we need it**:
    This PR fixes the bad column alignment.
    
    **Which issue(s) this PR fixes** 
    Fixes #56282 
    
    **Special notes for your reviewer**:
    I've aligned how `CustomColumnPrinter.PrintObj` handles tabwriter with how `HumanReadablePrinter.PrintObj` does it (see https://github.com/kubernetes/kubernetes/blob/master/pkg/printers/humanreadable.go#L299-L303)
    
    **Release note**:
    ```release-note
    Fixed column alignment when kubectl get is used with custom columns from OpenAPI schema
    ```
    9f4b851e
Name
Last commit
Last update
..
internalversion Loading commit data...
storage Loading commit data...
.import-restrictions Loading commit data...
BUILD Loading commit data...
OWNERS Loading commit data...
customcolumn.go Loading commit data...
customcolumn_flags.go Loading commit data...
customcolumn_flags_test.go Loading commit data...
customcolumn_test.go Loading commit data...
humanreadable.go Loading commit data...
humanreadable_flags.go Loading commit data...
humanreadable_flags_test.go Loading commit data...
humanreadable_test.go Loading commit data...
interface.go Loading commit data...
json.go Loading commit data...
json_yaml_flags.go Loading commit data...
json_yaml_flags_test.go Loading commit data...
jsonpath.go Loading commit data...
jsonpath_flags.go Loading commit data...
jsonpath_flags_test.go Loading commit data...
kube_template_flags.go Loading commit data...
name.go Loading commit data...
name_flags.go Loading commit data...
name_flags_test.go Loading commit data...
printers.go Loading commit data...
tabwriter.go Loading commit data...
template.go Loading commit data...
template_flags.go Loading commit data...
template_flags_test.go Loading commit data...
template_test.go Loading commit data...
versioned.go Loading commit data...