Skip to content

Conversation

irapandey
Copy link
Contributor

@irapandey irapandey commented Sep 18, 2025

What this PR does / why we need it:
This PR bumps up the github.com/olekukonko/tablewriter to latest (v1.0.9)

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #12318

/area misc

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-area PR is missing an area label labels Sep 18, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @irapandey. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Sep 18, 2025
@irapandey
Copy link
Contributor Author

// tbl.SetCenterSeparator("") 
// tbl.SetRowSeparator("")
// tbl.SetRowSeparator("")

These need not to be set separately as they are set by default as "" - https://github.com/olekukonko/tablewriter/blob/e520aed3bd36fcbc5935d6c4f778c38627788d1d/tw/symbols.go#L885

@irapandey irapandey force-pushed the tablewriter_12318 branch 2 times, most recently from d6abc40 to 54cab07 Compare September 19, 2025 10:37
@irapandey
Copy link
Contributor Author

ira@Iras-MacBook-Pro cluster-api % go test -v ./internal/util/tree
=== RUN   Test_getRowName
=== RUN   Test_getRowName/Row_name_for_objects_should_be_kind/name
=== RUN   Test_getRowName/Row_name_for_a_deleting_object_should_have_deleted_prefix
=== RUN   Test_getRowName/Row_name_for_objects_with_meta_name_should_be_meta-name_-_kind/name
=== RUN   Test_getRowName/Row_name_for_virtual_objects_should_be_name
=== RUN   Test_getRowName/Row_name_for_group_objects_should_be_#-of-items_kind
--- PASS: Test_getRowName (0.00s)
    --- PASS: Test_getRowName/Row_name_for_objects_should_be_kind/name (0.00s)
    --- PASS: Test_getRowName/Row_name_for_a_deleting_object_should_have_deleted_prefix (0.00s)
    --- PASS: Test_getRowName/Row_name_for_objects_with_meta_name_should_be_meta-name_-_kind/name (0.00s)
    --- PASS: Test_getRowName/Row_name_for_virtual_objects_should_be_name (0.00s)
    --- PASS: Test_getRowName/Row_name_for_group_objects_should_be_#-of-items_kind (0.00s)
=== RUN   Test_newConditionDescriptor_readyColor
=== RUN   Test_newConditionDescriptor_readyColor/True_condition_should_be_green
=== RUN   Test_newConditionDescriptor_readyColor/Unknown_condition_should_be_white
=== RUN   Test_newConditionDescriptor_readyColor/False_condition,_severity_error_should_be_red
=== RUN   Test_newConditionDescriptor_readyColor/False_condition,_severity_warning_should_be_yellow
=== RUN   Test_newConditionDescriptor_readyColor/False_condition,_severity_info_should_be_white
=== RUN   Test_newConditionDescriptor_readyColor/Condition_without_status_should_be_gray
--- PASS: Test_newConditionDescriptor_readyColor (0.00s)
    --- PASS: Test_newConditionDescriptor_readyColor/True_condition_should_be_green (0.00s)
    --- PASS: Test_newConditionDescriptor_readyColor/Unknown_condition_should_be_white (0.00s)
    --- PASS: Test_newConditionDescriptor_readyColor/False_condition,_severity_error_should_be_red (0.00s)
    --- PASS: Test_newConditionDescriptor_readyColor/False_condition,_severity_warning_should_be_yellow (0.00s)
    --- PASS: Test_newConditionDescriptor_readyColor/False_condition,_severity_info_should_be_white (0.00s)
    --- PASS: Test_newConditionDescriptor_readyColor/Condition_without_status_should_be_gray (0.00s)
=== RUN   Test_newConditionDescriptor_truncateMessages
=== RUN   Test_newConditionDescriptor_truncateMessages/Short_messages_are_not_changed
=== RUN   Test_newConditionDescriptor_truncateMessages/Long_message_are_truncated
--- PASS: Test_newConditionDescriptor_truncateMessages (0.00s)
    --- PASS: Test_newConditionDescriptor_truncateMessages/Short_messages_are_not_changed (0.00s)
    --- PASS: Test_newConditionDescriptor_truncateMessages/Long_message_are_truncated (0.00s)
=== RUN   Test_V1Beta1TreePrefix
=== RUN   Test_V1Beta1TreePrefix/First_level_child_should_get_the_right_prefix
=== RUN   Test_V1Beta1TreePrefix/Second_level_child_should_get_the_right_prefix
=== RUN   Test_V1Beta1TreePrefix/Conditions_should_get_the_right_prefix
=== RUN   Test_V1Beta1TreePrefix/Conditions_should_get_the_right_prefix_if_the_object_has_a_child
--- PASS: Test_V1Beta1TreePrefix (0.00s)
    --- PASS: Test_V1Beta1TreePrefix/First_level_child_should_get_the_right_prefix (0.00s)
    --- PASS: Test_V1Beta1TreePrefix/Second_level_child_should_get_the_right_prefix (0.00s)
    --- PASS: Test_V1Beta1TreePrefix/Conditions_should_get_the_right_prefix (0.00s)
    --- PASS: Test_V1Beta1TreePrefix/Conditions_should_get_the_right_prefix_if_the_object_has_a_child (0.00s)
=== RUN   Test_TreePrefix
=== RUN   Test_TreePrefix/Conditions_should_get_the_right_prefix_with_multiline_message
=== RUN   Test_TreePrefix/Conditions_should_get_the_right_prefix_with_multiline_message_and_a_child
=== RUN   Test_TreePrefix/Multiple_nested_childs_should_get_the_right_multiline_prefix
=== RUN   Test_TreePrefix/Nested_childs_should_get_the_right_prefix_with_multiline_message
=== RUN   Test_TreePrefix/Conditions_should_get_the_right_prefix_with_childs
--- PASS: Test_TreePrefix (0.00s)
    --- PASS: Test_TreePrefix/Conditions_should_get_the_right_prefix_with_multiline_message (0.00s)
    --- PASS: Test_TreePrefix/Conditions_should_get_the_right_prefix_with_multiline_message_and_a_child (0.00s)
    --- PASS: Test_TreePrefix/Multiple_nested_childs_should_get_the_right_multiline_prefix (0.00s)
    --- PASS: Test_TreePrefix/Nested_childs_should_get_the_right_prefix_with_multiline_message (0.00s)
    --- PASS: Test_TreePrefix/Conditions_should_get_the_right_prefix_with_childs (0.00s)
=== RUN   Test_formatParagraph
=== RUN   Test_formatParagraph/0
=== RUN   Test_formatParagraph/1
=== RUN   Test_formatParagraph/2
--- PASS: Test_formatParagraph (0.00s)
    --- PASS: Test_formatParagraph/0 (0.00s)
    --- PASS: Test_formatParagraph/1 (0.00s)
    --- PASS: Test_formatParagraph/2 (0.00s)
PASS
ok  	sigs.k8s.io/cluster-api/internal/util/tree	0.443s
ira@Iras-MacBook-Pro cluster-api %

@irapandey
Copy link
Contributor Author

The changes in go.sum and go.mod apart from the tablewriter originated from go mod tidy

@irapandey irapandey marked this pull request as ready for review September 19, 2025 10:39
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Sep 19, 2025
@irapandey
Copy link
Contributor Author

@irapandey
Copy link
Contributor Author

Screenshot 2025-09-19 at 4 39 25 PM

Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

best to show the before and after output in text / screenehots.

@neolit123
Copy link
Member

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 19, 2025
@irapandey
Copy link
Contributor Author

Hey @neolit123

I did tilt-up with main branch and my feature branch

With tablewriter v0.0.5
Screenshot 2025-09-22 at 9 44 29 AM

With tablewriter v1.0.9
Screenshot 2025-09-18 at 6 54 56 PM

The expected result for unit tests are unchanged and tests are passing successfully

@irapandey
Copy link
Contributor Author

WIP - linting with error message Error return value of ---- is not checked (errcheck)

Copy link
Member

@neolit123 neolit123 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

added some comments. thanks for the updates.
please keep the commits squashed to 1.

// Prints the output table
tbl.Render()
if err := tbl.Render(); err != nil {
fmt.Printf("Error rendering table: %v", err)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fprint to w. same for other cases below.

return tbl
}

// CreateObjectTreeV1Beta1 creates a new tablewriter.Table for the object tree.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can there be a single function?
if not best to clarify this in the comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose they can be clubbed in - there is a difference for an extra space
But they are different versions and clubbing together doesn't seem to be a great idea IMO

Thoughts? @sbueringer

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@neolit123 neolit123 Oct 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'm still in favor to have a single function.
function arguments can determine its behavior.

this part can be reused

	// Creates the output table
	tbl := tablewriter.NewTable(w, tablewriter.WithConfig(cfg), tablewriter.WithRendition(tw.Rendition{
		Settings: tw.Settings{
			Separators: tw.SeparatorsNone, Lines: tw.LinesNone,
		},
		Borders: tw.BorderNone,
	}))

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but looks like there are is further separation with addObjectRowV1Beta1 vs addObjectRow, so maybe just keep these separate functions for now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In general v1beta1 code will be deleted once we drop v1beta1 in a year or so

tbl.Render()
if err := tbl.Render(); err != nil {
fmt.Printf("Error rendering table: %v", err)
os.Exit(1)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

exiting from printing functions does not seem right. better to return errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure - I'll exit the function with return err message

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @neolit123 - I was working on returning the err instead of os.Exit - I found that returning error from these functions would impact whole lot of code in terms of error handling

Will have to catch the error as well - I suppose printing the error message should suffice - I am still confused though

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think last time @sivchari also mentioned to handle the error #12320 (comment),
I think may be you can handle error and and keep those changes in seperate commit, based on the further review we can decide later?

Copy link
Member

@neolit123 neolit123 Sep 25, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how did it work before this PR?
i did not see any exit calls in the old code or maybe i missed them.

it's an indication that the application is not organized well.
errors should propagate up to callers and ideally there shouldn't be any os.Exit calls in the code base other than the main.go. i suggest you do the necessary refactor in this PR in separate commits as @Karthik-K-N suggested ^

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

how did it work before this PR?
i did not see any exit calls in the old code or maybe i missed them.

I think in the previous version of tablewriter t.Render() never used to return error, Its new in this update.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup - the functions append() and render() have now started to return errors - it's one of the major changes in the v1.0.0+ release pf tablewriter package

I'll do the error handling in a separate commit as suggested

Thanks 😄

@sbueringer
Copy link
Member

@neolit123

please keep the commits squashed to 1.

Usually we don't enforce this in CAPI and just use the squash merge method with tide. Is there a problem with that?

@neolit123
Copy link
Member

@neolit123

please keep the commits squashed to 1.

Usually we don't enforce this in CAPI and just use the squash merge method with tide. Is there a problem with that?

nukes gpg signatures, but most commiters don't use them and therefore they will not require you later to revert their unsigned commits.

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 23, 2025
@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. area/clusterctl Issues or PRs related to clusterctl approved Indicates a PR has been approved by an approver from all required OWNERS files. and removed do-not-merge/needs-area PR is missing an area label labels Oct 6, 2025
@sbueringer
Copy link
Member

/assign @fabriziopandini

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 7, 2025
@sbueringer
Copy link
Member

@irapandey Can you please rebase? Thank you!

Copy link
Member

@fabriziopandini fabriziopandini left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great work!
just a few nits from my side

@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 10, 2025
@irapandey
Copy link
Contributor Author

Hey @fabriziopandini - I was on a short break - will make the changes today EOD

@fabriziopandini
Copy link
Member

Sure, thank you!

@fabriziopandini
Copy link
Member

Thanks for this PR!
/lgtm
/approve

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 15, 2025
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 364a3172a4a24118cbe20881c7bca70c6e950e82

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: fabriziopandini, neolit123

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:
  • OWNERS [fabriziopandini,neolit123]

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@fabriziopandini
Copy link
Member

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Oct 15, 2025
@k8s-ci-robot k8s-ci-robot merged commit 195a243 into kubernetes-sigs:main Oct 15, 2025
17 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.12 milestone Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. area/clusterctl Issues or PRs related to clusterctl cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. tide/merge-method-squash Denotes a PR that should be squashed by tide when it merges.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update github.com/olekukonko/tablewriter to v1+

6 participants