-
Notifications
You must be signed in to change notification settings - Fork 205
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
Fix spec initializing copying wrong property #4108
Conversation
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.
Nice!
path []astmodel.PropertyName, | ||
) *TypedConversionEndpoint { | ||
var builder strings.Builder | ||
for i, name := range path { |
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.
minor: You could probably have used strings.Join
here, though it would require transforming the path to strings 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.
Changed.
// assign is a function that will be called for each matching property, with the source and destination endpoints | ||
// for that property. | ||
// Returns an error if any of the assignments fail. | ||
func (builder *PropertyAssignmentFunctionBuilder) selectIdenticallyPathedProperties( |
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.
extremely minor:
func (builder *PropertyAssignmentFunctionBuilder) selectIdenticallyPathedProperties( | |
func (builder *PropertyAssignmentFunctionBuilder) selectPropertiesWithIdenticalPaths( |
(avoids IdenticallyPathed
which read weird to me. Not sure it's really all that much better.)
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.
Done.
Seems some unit test failures @theunrepentantgeek |
What this PR does / why we need it:
In #3805, @nojnhuh noticed that
asoctl
was initializing thetype
field on an imported AgentPool with the wrong value.Investigation leads to the observation that properties with the same name don't necessarily have the same providence - not every
Type
field can be copied into anotherType
field.Special notes for your reviewer:
There are two fixes.
The first is to check the origin of each property, skipping the assign-identically-named-properties step if the properties came from different places
The second fix is to use the path-of-origin of the remaining properties to match things up. This is complicated by the possibility that the property may be configurable - so we would have both
Type
andTypeFromConfig
as candidates. We disambiguate these by doing a fast and loose compatibility check on the types, which seems good enough.How does this PR make you feel:
If applicable: