-
Notifications
You must be signed in to change notification settings - Fork 465
Non-breaking feature: ✨ deepcopy - do not generate empty import #1321
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: ivan katliarchuk <[email protected]>
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: ivankatliarchuk The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
|
/retest |
| By("checking for errors") | ||
| Expect(hadErrs).To(BeFalse()) |
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.
Why is this so late? Surely you want to check this straight after the Run, else the rest of the test doesn't make a lot of sense?
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 copied same pattern as in other test
| Expect(hadErrs).To(BeFalse()) |
pkg/deepcopy/gen_test.go
Outdated
| output := buf.String() | ||
|
|
||
| // Check for empty import block "import ()" | ||
| if strings.Contains(output, "import (\n)") { |
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.
Would it normally do import () or import( with a newline before the closing )?
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.
Signed-off-by: ivan katliarchuk <[email protected]>

Controller-gen was generating empty
import ()blocks in DeepCopy files when types didn't require external dependenciesModified the writeHeader function to conditionally generate import blocks:
Create unit test Unit Tests.
Added comprehensive E2E test that:
Before (with empty imports):
After (clean output):