Closed
Description
Feature Idea
During a reconcile, I try to access a specific secondary resource. For example, I manage multiple config maps that are all owned by the same primary resource. In the reconcile I would like to access a specific resource that I can name by "namespace" + "name". In v2, there was a ResourceID, which was useable to access the event source cache.
The current possible solution would be:
<Optional>ConfigMap getConfigMap(Context<X> context, String name, String namespace) {
return context.getSecondaryResources(ConfigMap.class).stream().filter(
c -> namespace.equals(c.getMetadata().getNamespace()) &&
namespace.equals(c.getMetadata().getName())).findFirst();
}
But I'd rather have a more specific access method
<Optional>ConfigMap getConfigMap(Context<X> context, String name, String namespace) {
return context.getSecondaryResource(ConfigMap.class).get(new ResourceID(namespace, name);
}
Metadata
Metadata
Assignees
Labels
No labels
Activity
csviri commentedon Aug 22, 2022
(we already touched the topic on discord will add here a summary).
It the reconciler has a reference for the
InformerEventSource
this is already possible just by calling this method:https://github.com/java-operator-sdk/java-operator-sdk/blob/1961be8427682f6dbd9383c7399d41a90eef3439/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/processing/event/source/informer/ManagedInformerEventSource.java#L93
In case of dependent resource it might still be needed for example to calculate the status. But in case of managed dependent resources the event sources are not accessible. We might want to give access to them through the
Context
. cc @metacosmThis PR expands on this idea and make it possible event to access additional indexes on event sources:
#1378
It might be an option to have a predefined generic Discriminator that just calls the get method with the resource id. Will take a look how it might look like.