Skip to content

conversion-gen should be able to use conversion functions defined in other packages #94

Open
@ncdc

Description

@ncdc

Let's say I have the following package structure:

  • a1
    • types.go (Widget)
    • sub1
      • types.go (Fromble)
  • a2
    • types.go (Widget)
    • sub2
      • types.go (Fromble)

and types like

// a1
type Widget struct {
  f sub1.Fromble
}

// a2
type Widget struct {
  f sub2.Fromble
}

I'd like to be able to generate conversion functions for sub1/sub2. Then I'd like to generate conversion functions for a1/a2 and have them use the generated conversion functions from sub1/sub2. I haven't found a way to do this. I've trying using --extra-peer-dirs, but all the generated files are currently using the default build tag (ignore_autogenerated), and gengo purposefully excludes these files:

https://github.com/kubernetes/gengo/blob/e0e292d8aa122d458174e1bef5f142b4d0a67a05/args/args.go#L137-L138

I could potentially use a unique tag per package & generator, but I have a real world example where some of the packages come from other repositories, and it's not easy to change their tags.

Is there a way to make this work with conversion-gen as-is, or will it require changes, either to conversion-gen or gengo?

cc @sttts @vincepri @yastij

Metadata

Metadata

Assignees

No one assigned

    Labels

    lifecycle/frozenIndicates that an issue or PR should not be auto-closed due to staleness.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions