feat(core): add by-name secondary resource lookup on Context#3373
Conversation
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Adds new Context APIs for retrieving secondary resources by ResourceID and streaming secondary resources from a specific named event source, with cache-backed fast paths and tests to validate behavior.
Changes:
- Added
Context#getSecondaryResource(..., ResourceID)and a convenience overload that infers namespace from the primary resource. - Added
Context#getSecondaryResourcesAsStream(..., eventSourceName)with aResourceCachefast path for read-cache-after-write consistency. - Expanded
DefaultContextTestto cover cache hit/miss, fallback behavior, cluster-scoped vs namespaced primaries, and workflow-managed missing event sources.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
| File | Description |
|---|---|
| operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/Context.java | Introduces new public API methods and Javadoc for ResourceID lookups and named event-source streaming. |
| operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/reconciler/DefaultContext.java | Implements the new APIs, adds cache/resource-cache fast paths, and refactors missing-event-source handling into a helper. |
| operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/reconciler/DefaultContextTest.java | Adds unit tests validating the new APIs and fast-path/fallback behaviors. |
495d579 to
c8b2feb
Compare
c8b2feb to
1012314
Compare
csviri
left a comment
There was a problem hiding this comment.
Thank you for the PR @afalhambra-hivemq !
Could you pls target 'next' branch so this ends up in next minor release rather than in next patch release.
I was also thinking if we should use ResourceID in the method or simply name and namespace directly it might be less user boilerplate code at the end,or? What do you think?
1012314 to
83dbac3
Compare
xstefank
left a comment
There was a problem hiding this comment.
LGTM, just please change the target branch and the @since tags. Thanks!
83dbac3 to
1b3bfe4
Compare
Agree, cleaner and less boilerplate for customers. Also targeting |
1b3bfe4 to
4b4da08
Compare
Signed-off-by: Antonio Fernandez Alhambra <antonio.alhambra@hivemq.com>
4b4da08 to
51b5e6f
Compare
Adds three typed by-name secondary-resource accessors to
Context<P>:<R extends HasMetadata> Optional<R> getSecondaryResource(Class<R>, String eventSourceName, ResourceID)(abstract)<R extends HasMetadata> Optional<R> getSecondaryResource(Class<R>, String eventSourceName, String name)(default; uses the primary's namespace)<R extends HasMetadata> Stream<R> getSecondaryResourcesAsStream(Class<R>, String eventSourceName)(abstract)Closes #3372