-
Notifications
You must be signed in to change notification settings - Fork 209
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
Add support for discontinuous property conversions #3641
Add support for discontinuous property conversions #3641
Conversation
Codecov ReportAttention:
Additional details and impacted files@@ Coverage Diff @@
## main #3641 +/- ##
==========================================
- Coverage 53.58% 53.45% -0.14%
==========================================
Files 1411 1417 +6
Lines 483451 484060 +609
==========================================
- Hits 259079 258731 -348
- Misses 185153 186094 +941
- Partials 39219 39235 +16 ☔ View full report in Codecov by Sentry. |
1671f7b
to
1fca1b7
Compare
// Require a path from one name to the next, and work out an intermediate step to break down the conversion | ||
var intermediateName astmodel.InternalTypeName | ||
if conversionContext.PathExists(sourceName, destinationName) { | ||
var err error |
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.
Can move this(and below) var outside the if
statements and to the error checking after the if-else
blocks?
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 could, but I prefer keeping things tightly scoped.
We need intermediateName
after the if, but we don't need either of the potential errors later on. Moving the err
variable outside implies a need to access the error again, which isn't correct.
|
||
next, err := graph.FindNextType(current, nil) | ||
if err != nil { | ||
break |
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.
Should we be doing something with this error?
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.
If there's an actual problem (other than no next type) that'll be reported elsewhere. So I think this one is safe to ignore.
c.start, | ||
func(t astmodel.InternalTypeName) bool { | ||
count++ | ||
return t == c.end |
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.
Should we be using .Equals
here?
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 don't think we need to - we're comparing InternalTypeName
instances, which are value types, not reference - and we don't need any of the special support from .Equals
.
} | ||
|
||
if intermediateName.IsEmpty() || astmodel.TypeEquals(intermediateName, sourceName) { | ||
if intermediateName.IsEmpty() || | ||
astmodel.TypeEquals(intermediateName, sourceName) || |
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: Should there be a comment here explaining the situations where the intermediate name is the source or destination?
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.
Added.
// | ||
// Note the actual steps are generated by nested conversions; this handler works by finding the two conversions needed | ||
// given our intermediate type and chaining them together. | ||
func assignNoninlineObjectsViaPivotObject( |
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, should this be:
func assignNoninlineObjectsViaPivotObject( | |
func assignNonInlineObjectsViaPivotObject( |
Since I think non-inline
would be cased like that?
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.
What this PR does / why we need it:
We've had the assumption that two properties needing conversion would have line-of-sight to each other in the storage conversion graph constructed by the generator. To this point this has been true, but with a recent attempt to import another preview version of
ManagedCluster
we discovered that this was not so.To support these conversions, I've added another conversion handler, one that looks for a commonly visible pivot type that can be used to build the conversion required.
Special notes for your reviewer:
I've also refactored creation of test cases for property conversions - the existing test case factory method was too large and complicated to comprehend; now the various groups of test cases are split up.
How does this PR make you feel:
If applicable: