-
Notifications
You must be signed in to change notification settings - Fork 123
refactor: Extract common resource fields into a separate embedded struct #3571
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
Conversation
bundle/config/resources/apps.go
Outdated
| ID string `json:"id,omitempty" bundle:"readonly"` | ||
| // We cannot embed BaseResource here because apps.App has its own Id field | ||
| // that conflicts with BaseResource.ID | ||
| ID string `json:"id,omitempty" bundle:"readonly"` |
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.
Question - where does this conflict manifests? Curious why it's a problem for 2 embedded structs but not a problem for outer + embeded.
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 suspect it's a precedence thing where the second embedded struct takes precedence over the first.
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.
in that case swapping order would allow to use embedded one here?
BTW URL also overlaps for Apps
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 think it's still the same problem with outer + embedded, it's just that linter does not catch it, I fixed it here to use BaseResource for apps and pipelines anyway
d584606
|
pietern
left a comment
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.
@andrewnester Any ideas if we could fix the cases where we can't embed it? It almost defies the purpose of having a single base struct to reuse, if we have to copy/paste fields to the cases where it doesn't work anyway.
Changes
Extract common resource fields into a separate embedded struct
BaseResourceWhy
Based on feedback from #3448 (comment)
Tests
Existing tests pass