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. labels Sep 18, 2025
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign neolit123 for approval. For more information see the Code Review Process.

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

Needs approval from an approver in each of these files:

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

@k8s-ci-robot k8s-ci-robot added the do-not-merge/needs-area PR is missing an area label label Sep 18, 2025
@k8s-ci-robot
Copy link
Contributor

This PR is currently missing an area label, which is used to identify the modified component when generating release notes.

Area labels can be added by org members by writing /area ${COMPONENT} in a comment

Please see the labels list for possible areas.

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
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

Used this guide to migrate from v0.0.5 to v1.0.0+ - https://github.com/olekukonko/tablewriter/blob/e520aed3bd36fcbc5935d6c4f778c38627788d1d/MIGRATION.md

@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.

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 removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. do-not-merge/needs-area PR is missing an area label 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.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update github.com/olekukonko/tablewriter to v1+
5 participants