-
Notifications
You must be signed in to change notification settings - Fork 238
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
feat: templating tool for direct controller builder #1996
feat: templating tool for direct controller builder #1996
Conversation
b7a8fe4
to
6c9f55f
Compare
6c9f55f
to
6766368
Compare
return controllerFilePath, nil | ||
} | ||
|
||
func FormatImports(path string, out []byte) 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.
Nice!
} | ||
|
||
func WriteToFile(path string, out []byte) error { | ||
f, err := os.Create(path) |
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.
Nit: I don't think you need (or should) call os.Create here. os.WriteFile creates the file IIRC.
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 you want to check that the file doesn't exist, you should basically inline WriteFile, passing some different options to os.OpenFile IIRC)
} | ||
|
||
func WriteToFile(path string, out []byte) error { | ||
f, err := os.Create(path) |
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 you want to check that the file doesn't exist, you should basically inline WriteFile, passing some different options to os.OpenFile IIRC)
Looks great. Once we have a template we can start adding commands / tweaking the template as we see fit. Really happy to see this 🎉 /approve |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: justinsb 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 |
04064f0
into
GoogleCloudPlatform:master
Example
cd dev/tools/controllerbuilder