operator-framework / operator-framework/java-operator-sdk

Inject config into a KubernetesDependentResource

Abierto
#2,087 5 comentarios 0 reacciones 2 asignados Ver en GitHub

@metacosm ya está trabajando en esto.

Desde el 11/10/2023.

  • #2088 de @csviri — cerrado sin fusionar
kind/documentation lifecycle/stale
Lenguaje dominante
Java
Estrellas
944
Forks
242
Merge medio
1 d 4 h
PR fusionados (30 d)
43

Descripción

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?

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.