operator-framework / operator-framework/java-operator-sdk
Inject config into a KubernetesDependentResource
オープン
kind/documentation
lifecycle/stale
- 主要言語
- Java
- スター
- 944
- フォーク
- 242
- 平均マージ
- 1日 4時間
- マージ済み PR(30日)
- 43
説明
I'm trying to inject some dependencies into my KubernetesDependentResource.
For dependent resources I usually do this by implementing DependentResourceConfigurator:
// Dependent resource
public class MyDependentResource
extends PerResourcePollingDependentResource<MyDependent, MyPrimary>
implements DependentResourceConfigurator<MyConfig> {
@Override
public void configureWith(MyConfig config) {
this.dependency1 = config.dependency1();
}
}
// Startup code
Operator operator = new Operator();
operator.register(reconciler, r -> r.replaceNamedDependentResourceConfig(MyDependentResource.NAME, new MyConfig(/*...*/)));
But KubernetesDependentResource already implements DependentResourceConfigurator, so I can't configure my own config.
Currently working around this issue by using a singleton pattern.
I inject the dependencies into the singleton and initialise it before the dependent resource reconciler is created.
The dependent resource reconciler then fetches its dependencies from the singleton.
Is there a different way to do this?
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
評価
この issue はまだ評価されていません。