-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
🌱 Add util which is able to merge golang source code fragments based custom rules #4540
base: master
Are you sure you want to change the base?
Conversation
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: dmvolod 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 |
Hi @dmvolod. 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. |
/assign @camilamacedo86 |
@@ -18,6 +18,7 @@ require ( | |||
) | |||
|
|||
require ( | |||
github.com/dave/dst v0.27.3 // indirect |
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.
We need to be very conscious about the added deps.
I do not think that we can move within, but I want to check your approach
It seems very interesting 🥇
Thank you for sharing.
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.
Yes, totally agree with you about dependencies policy
Golang core has it's own AST parser, but according to the issues at https://github.com/golang/go it's unusable in most cases I and can see.
"golang.org/x/tools/go/ast/astutil" | ||
) | ||
|
||
func InsertCode(filename, code string) error { |
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.
Let's first check the approach. I do not want you to spend an effort that will not be constructive.
However, as you know, in the plugin/utils, we have a helper to insert code, replace, etc.
So, we would need to use what we have already.
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.
Good point
I saw this code, but looks like it's just manipulate code as text, but this is manipulation code as code.
But I understand, its enough for most cases, probably except the current one or similar few cases.
This is small util library which as able to merge golang source code fragments based custom rules
Custom rules is a special function who decide how and when merge similar code fragment.
Not all cases are currently handled, but need to decide is it suitable approach for current task or not.
Preview for #4146
/hold