Skip to content
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

Unable to conversion-gen conversions that require a conversion.Scope #810

Open
ncdc opened this issue Feb 20, 2020 · 6 comments
Open

Unable to conversion-gen conversions that require a conversion.Scope #810

ncdc opened this issue Feb 20, 2020 · 6 comments
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done.
Milestone

Comments

@ncdc
Copy link
Contributor

ncdc commented Feb 20, 2020

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?

@vincepri
Copy link
Member

/priority awaiting-more-evidence
/help

@k8s-ci-robot
Copy link
Contributor

@vincepri:
This request has been marked as needing help from a contributor.

Please ensure the request meets the requirements listed here.

If this request no longer meets these requirements, the label can be removed
by commenting with the /remove-help command.

In response to this:

/priority awaiting-more-evidence
/help

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. labels Feb 21, 2020
@vincepri vincepri added this to the Next milestone Feb 21, 2020
@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label May 21, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jun 20, 2020
@vincepri
Copy link
Member

/lifecycle frozen

@k8s-ci-robot k8s-ci-robot added lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. and removed lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. labels Jun 22, 2020
@ANeumann82
Copy link

I ran into the same issue - conversion-gen is great to generate the default conversions between api versions, and controller-runtime is great for providing an easy setup for a conversion webhook, but I don't see a way to connect both nicely together. the conversion.Scope is required for the generated code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Denotes an issue that needs help from a contributor. Must meet "help wanted" guidelines. lifecycle/frozen Indicates that an issue or PR should not be auto-closed due to staleness. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done.
Projects
None yet
Development

No branches or pull requests

5 participants