-
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
🌱 : Improve samples linting & fix samples lint issues #4548
Conversation
|
Welcome @wazery! |
Hi @wazery. 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. |
I hope my changes to the cronjob_controller.go don't introduce any issues with the docs. I am trying to generate them and validate in the meantime. |
...ok/src/multiversion-tutorial/testdata/project/internal/controller/cronjob_controller_test.go
Show resolved
Hide resolved
@@ -1,3 +1,5 @@ | |||
# Image URL to use all building/pushing image targets | |||
IMG ?= controller:latest |
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.
That’s interesting! 🤔
I think the plugin could definitely have more targets—many of them would be valuable here, though not all from the default scaffold.
Just a quick note: this sample is actually an external plugin, meaning it will be packaged as a binary that generates scaffolds, similar to Kubebuilder. However, it is designed to work alongside Kubebuilder to extend functionality rather than replace its core scaffolding. More details here: External Plugins.
Given that, I’d recommend reverting the changes in this PR.
If you’d like to improve the plugin by adding meaningful targets, that can definitely be done—but in a separate PR. We’ll also need to carefully evaluate which targets make sense for this context.
For example, we should not include targets like docker build for building a container image, because this project does not include a manager, Dockerfile, or containerized components, and it shouldn’t require them.
Hope this clarifies! Let me know your thoughts. 🚀
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 that truly makes perfect sense now to me. Will update the PR accordingly, thanks for the review.
6071a54
to
f05a50b
Compare
f05a50b
to
fe2fa2f
Compare
@camilamacedo86 updated the PR accordingly now. Truly appreciated the kind guidance 🙇 . |
fe2fa2f
to
973f5c1
Compare
973f5c1
to
2fdd664
Compare
2fdd664
to
4ac8e88
Compare
return ctrl.Result{}, err | ||
} | ||
if cronJob == nil { | ||
return ctrl.Result{}, nil // CronJob deleted | ||
} |
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 cannot remove the previous content or the comments it is part of your docs/tutorials.
We just need to address the lint issues but keep all as before.
What lint issue are you facing here?
docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller.go
Outdated
Show resolved
Hide resolved
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.
Hi @wazery
Great work 🥇
Just one thing here shows not accurate
We cannot change the docs/book/src/cronjob-tutorial/testdata/project/internal/controller/cronjob_controller.go
at this away because it is used in the docs tutorial and those will broke it out.
I understand that the lint issue that you tried to solve is that the func has more than 30 lines, in this case we need add on top of the func // nolint:<name of lint>
to ignore this case.
4ac8e88
to
764ca45
Compare
/ok-to-test Great work 🥇 🚀 Just I nit I will change the emoji because we use it to generate the release. |
I am not sure why the Testdata verification workflow fails, although when I run locally |
Hi @wazery I think it still not properly updated.
The validation just run the commands and check if has a git diff. |
764ca45
to
79cbe34
Compare
I recreated the branch on latest master, reran the make install & generate commands and committed. Hope now it passes. |
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.
/lgtm
Hi @wazery The lint has failures git checkout master git checkout this-branch |
This commit includes: - Fix linter issues - Refactor fetchCronJob in sample controller reconcile func - Fix getting-started tutorial lint issues - Fix multiversion tutorial lint issues - Fix cronjob-tutorial lint issues - Refactor cronjob controller reconcile to reduce cyclomatic complexity
79cbe34
to
0c4ce6d
Compare
@camilamacedo86 I fixed the issue, it was mainly that I introduced a run for goimports to reformat the file after generating it, but it seems this is an overkill. I removed that and rather fixed the format issue manually in the scripts so it will generate properly formatted code. |
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.
/lgtm
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: camilamacedo86, wazery 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 |
✨ Summary
This PR enhances code quality and maintainability by addressing various linter issues and improving the CronJob controller Reconcile function code structure to reduce the cyclomatic complexity.
What's included in the PR:
Motivation:
The goal of this PR is to enhance the overall linting coverage of sample code, ensuring that all included examples meet best practices. By addressing lint issues and integrating more samples, this change improves code consistency.
Fixes: #4445