-
Notifications
You must be signed in to change notification settings - Fork 1.4k
🌱 Bumping tablewriter to v1.0.9 - latest #12781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
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 Once the patch is verified, the new status will be reflected by the 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. |
These need not to be set separately as they are set by default as |
d6abc40
to
54cab07
Compare
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 % |
The changes in go.sum and go.mod apart from the tablewriter originated from |
Used this guide to migrate from |
There was a problem hiding this 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.
/ok-to-test |
Hey @neolit123 I did tilt-up with main branch and my feature branch The expected result for unit tests are unchanged and tests are passing successfully |
WIP - linting with error message |
There was a problem hiding this 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.
internal/util/tree/tree.go
Outdated
// Prints the output table | ||
tbl.Render() | ||
if err := tbl.Render(); err != nil { | ||
fmt.Printf("Error rendering table: %v", err) |
There was a problem hiding this comment.
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. |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
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,
}))
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
internal/util/tree/tree.go
Outdated
tbl.Render() | ||
if err := tbl.Render(); err != nil { | ||
fmt.Printf("Error rendering table: %v", err) | ||
os.Exit(1) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 ^
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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 😄
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. |
dd9cf0e
to
a478afc
Compare
a478afc
to
6262377
Compare
6262377
to
c0a7775
Compare
d4bf079
to
51acf57
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems there is some sort of a bug on the github ui.
Files changed are 10 but there are only 2 listed in the diff.
anyone else seeing this?
} | ||
|
||
// CreateObjectTreeV1Beta1 creates a new tablewriter.Table for the object tree. | ||
// Returns a new tablewriter.Table for the object tree. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if the two separate functions are kept, best to properly add the Godoc comment here and explain how they differ.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah - I have been playing around with options as the diff is merely a space worth of padding
I suppose something like this might be useful
// CreateObjectTree creates a new tablewriter.Table for the object tree.
// Returns a new tablewriter.Table for the object tree.
func CreateObjectTree(w io.Writer) *tablewriter.Table {
return createObjectTreeWithPadding(w, " ")
}
// CreateObjectTreeV1Beta1 creates a new tablewriter.Table for the object tree.
// Returns a new tablewriter.Table for the object tree.
func CreateObjectTreeV1Beta1(w io.Writer) *tablewriter.Table {
return createObjectTreeWithPadding(w, " ")
}
// createObjectTreeWithPadding creates a new tablewriter.Table for the object tree with the specified right padding.
func createObjectTreeWithPadding(w io.Writer, rightPadding string) *tablewriter.Table {
cfg := tablewriter.Config{
Row: tw.CellConfig{
Formatting: tw.CellFormatting{AutoWrap: tw.WrapNone},
Alignment: tw.CellAlignment{Global: tw.AlignLeft},
Padding: tw.CellPadding{Global: tw.Padding{Left: "", Right: rightPadding}},
},
Header: tw.CellConfig{
Alignment: tw.CellAlignment{Global: tw.AlignLeft},
},
Behavior: tw.Behavior{TrimSpace: tw.Off},
}
// 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,
}))
return tbl
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if all the functions that have a v1beta1 suffix can be merged with the versions without the suffix that would be ideal as long as it's a simple change.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose that can be done - but the PR would keep stretching on - I can open an issue to make those changes
"Merge all v1beta1 functions into generic functions"
I would need to understand why they are separate in the first place
seemed like a temporary bug, it showed 2 files changed for all commits. after a few refreshes it's now working. |
/label tide/merge-method-squash |
best for someone else to review as well. /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: 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:
Approvers can indicate their approval by writing |
/assign @fabriziopandini |
PR needs rebase. 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. |
@irapandey Can you please rebase? Thank you! |
There was a problem hiding this 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
if err := tbl.Render(); err != nil { | ||
fmt.Printf("Error rendering table: %v", err) | ||
os.Exit(1) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should this be
if err := tbl.Render(); err != nil { | |
fmt.Printf("Error rendering table: %v", err) | |
os.Exit(1) | |
} | |
g.Expect( tbl.Render()).To(Succeed(), "Error rendering table") |
(same in Test_TreePrefix)
|
||
// CreateObjectTree creates a new tablewriter.Table for the object tree. | ||
// Returns a new tablewriter.Table for the object tree. | ||
func CreateObjectTree(w io.Writer) *tablewriter.Table { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this be
func CreateObjectTree(w io.Writer) *tablewriter.Table { | |
func createObjectTree(w io.Writer) *tablewriter.Table { |
Same for createObjectTreeV1Beta1
Header: tw.CellConfig{ | ||
Alignment: tw.CellAlignment{Global: tw.AlignLeft}, | ||
}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a quick test, if we set
Header: tw.CellConfig{ | |
Alignment: tw.CellAlignment{Global: tw.AlignLeft}, | |
}, | |
Formatting: tw.CellFormatting{AutoWrap: tw.WrapNone}, | |
Alignment: tw.CellAlignment{Global: tw.AlignLeft}, | |
Padding: tw.CellPadding{Global: tw.Padding{Left: "", Right: " "}}, |
We get a more consistent alignment between headers and rows, wdyt?
(same for CreateObjectTreeV1Beta1)
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