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

オープン
#810 コメント 9 件 リアクション 2 件 担当者 0 名 GitHub で見る

メンテナーはふだん 1 日以内に返信

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
25/100
issue の種類
バグ
明瞭さ
説明が足りない
活発さ
停滞
技術スタック
go
領域
tooling

調査の方向性

まず、issue に示されている conversion-gen の出力と、変換機構で使用されている conversion.Scope の実装を追跡します。次に、ConvertTo および ConvertFrom の実装が Scope にアクセスする方法として想定されているものと、code-generator issue 94 で説明されている制限を調査します。Scope を必要とする生成済み変換を使用するためのサポートされた方法を確立するか、そのような方法が存在しないことを文書化できれば完了です。

索引モデルが issue の本文から書いたものです。

説明

help wanted lifecycle/frozen priority/awaiting-more-evidence

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?

主要言語
Go
スター
3k
フォーク
1.3k
平均マージ
1日 7時間
マージ済み PR(30日)
48

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

kubernetes-sigs/controller-runtime のほかの issue

kubernetes-sigs/controller-runtime の issue をすべて見る

似ている issue

Go の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。