-
Notifications
You must be signed in to change notification settings - Fork 68
Conversation
We invoke goimports in two places: 1. Automatically on generated files. 2. When running make imports 1 is bad practice; we should not edit generated code, even using tools. 2 is redundant; make lint invokes goimports via golangci-lint. Signed-off-by: Nic Cope <negz@rk0n.org>
Some context on this PR: I just lost an hour due to a bug in goimports. Running make generate in stack-azure was deleting corev1 imports from generated deepycopy files, despite them being needed by those files. Turns out make generate invokes goimports on generated files, does not use a pinned version of goimports, and the version of goimports I had cached had a bug in it. |
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
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 originally added this in e0558c9 during the migration to kubebuilder v2 because the generated files were failing linting checks (they weren't goimports
valid), which was failing the builds. Do we no longer have this problem and the builds will still succeed after this invocation of goimports
is removed?
@jbw976 Was it |
@negz I am not actually sure which specific tool it was (or if it was even linting at all), but a simple |
@jbw976 I tested it with stack-aws, but I just now tried stack-gcp and can reproduce the issue you were seeing. I've confirmed that if I add the following to run:
skip-files:
- "zz_generated\\..+\\.go$" My suggestion would be to add the above to the linter config in each repo - I don't think there's much value in linting generated code. I'll open PRs for that now. |
That sounds very reasonable, thank you for checking on that @negz! so we can go ahead and merge this then, and then pick up the new build submodule hash along with updating the |
Cross-linking some prior art here:
|
upbound/build#88 This results in a diff because we no longer run goimports on generated files. Signed-off-by: Nic Cope <negz@rk0n.org>
upbound/build#88 This results in a diff because we no longer run goimports on generated files. Signed-off-by: Nic Cope <negz@rk0n.org>
upbound/build#88 This results in a diff because we no longer run goimports on generated files. Signed-off-by: Nic Cope <negz@rk0n.org>
upbound/build#88 This results in a diff because we no longer run goimports on generated files. Signed-off-by: Nic Cope <negz@rk0n.org>
We invoke goimports in two places:
1 is bad practice; we should not edit generated code, even using tools. 2 is redundant; make lint invokes goimports via golangci-lint.