kubernetes-sigs / kubernetes-sigs/controller-runtime
Unable to conversion-gen conversions that require a conversion.Scope
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 3k
- Forks
- 1.3k
- Avg merge
- 2d 5h
- Merged PRs (30d)
- 14
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 https://github.com/kubernetes/code-generator/issues/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?
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the conversion-gen output shown in the issue and the conversion.Scope implementation used by the conversion machinery. Then inspect how ConvertTo and ConvertFrom implementations are expected to access a scope, along with the limitation described in code-generator issue 94. Done means establishing a supported way to use generated conversions requiring a Scope, or documenting that no such path exists.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100