Skip to content
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

Merged

Conversation

yuwenma
Copy link
Collaborator

@yuwenma yuwenma commented Jun 12, 2024

Example

cd dev/tools/controllerbuilder
go run main.go --service cloudbuild --version v1alpha1 --resourceInKind WorkerPool

@yuwenma yuwenma force-pushed the controller-builder branch from 6c9f55f to 6766368 Compare June 19, 2024 06:13
return controllerFilePath, nil
}

func FormatImports(path string, out []byte) error {
Copy link
Collaborator

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)
Copy link
Collaborator

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.

Copy link
Collaborator

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)
Copy link
Collaborator

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)

@justinsb
Copy link
Collaborator

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

Copy link
Contributor

[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 /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@google-oss-prow google-oss-prow bot merged commit 04064f0 into GoogleCloudPlatform:master Jun 22, 2024
13 checks passed
@yuwenma yuwenma added this to the 1.120 milestone Jun 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants