improve: getSecondaryResourcesAsStream(expectedType,eventSourceName) does not have to be Kubernetes resources#3377
Conversation
…does not have to be Kubernetes resources Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
|
@afalhambra-hivemq FYI just a small adjustment for this one method. Pls let us know if it makes sense also for you. |
There was a problem hiding this comment.
Pull request overview
This PR broadens the Context#getSecondaryResourcesAsStream(Class, String) API so it can be used with non-Kubernetes (non-HasMetadata) secondary resources, aligning it with the framework’s support for external event sources.
Changes:
- Relaxed the generic bound on
getSecondaryResourcesAsStream(Class<R>, String eventSourceName)fromR extends HasMetadatato unconstrainedR. - Updated
DefaultContextto match the interface signature change.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Context.java | Updates the public Context API signature to allow streaming non-HasMetadata secondary resources from a named event source. |
| operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/DefaultContext.java | Aligns the concrete implementation method signature with the updated Context contract. |
| */ | ||
| <R extends HasMetadata> Stream<R> getSecondaryResourcesAsStream( | ||
| Class<R> expectedType, String eventSourceName); | ||
| <R> Stream<R> getSecondaryResourcesAsStream(Class<R> expectedType, String eventSourceName); |
|
|
||
| @Override | ||
| public <R extends HasMetadata> Stream<R> getSecondaryResourcesAsStream( | ||
| public <R> Stream<R> getSecondaryResourcesAsStream( |
@csviri, yes, makes sense to me. The stream method's fallback doesn't do anything HasMetadata-specific, and the fast path's constraint comes from ResourceCache itself anyway. No impact on us. |
In a previous PR we added overloaded functions for accessing resources from event sources. Some of those were limited to Kubernetes resources. I've just realized that this one should not be one of them.