Description
Some functions autogenerated by conversion-gen produce code that looks like this:
func autoConvert_v1alpha1_Something_To_v1alpha2_Something(in *Something, out *v1alpha2.Something, s conversion.Scope) error {
// normal convertible fields
out.X = in.X
// TODO: Inefficient conversion - can we improve it?
if err := s.Convert(&in.SomeField, &out.SomeField, 0); err != nil {
return err
}
return nil
}
The "inefficient conversion" can happen in a few different situations; in this case, it's because SomeField
is a struct that lives in a package outside of the one where I'm generating conversions. Due to kubernetes/code-generator#94 (assuming there isn't a workaround), even if there were conversion functions for SomeField
, conversion-gen isn't able to see & use them.
We presumably need access to a conversion.Scope
in our ConvertTo
/ConvertFrom
implementations, but these are member functions on the types, and I haven't yet found any way to get access to a Scope
(this appears to have a single, unexported implementation that is used internally by the conversion machinery code).
Anyone know of a way to use generated conversion functions that need a Scope
?