Skip to content

Conversation

@metacosm
Copy link
Collaborator

@metacosm metacosm commented Jan 29, 2026

Alternative to #3130, to discuss

csviri and others added 8 commits January 28, 2026 08:23
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
…tor/api/reconciler/ReconcileUtils.java

Co-authored-by: Martin Stefanko <xstefank122@gmail.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Attila Mészáros <a_meszaros@apple.com>
Signed-off-by: Chris Laprun <metacosm@gmail.com>
@openshift-ci openshift-ci bot added the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Jan 29, 2026
@openshift-merge-robot openshift-merge-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 29, 2026
@metacosm metacosm changed the base branch from main to next January 29, 2026 22:10
@metacosm metacosm requested review from csviri and xstefank and removed request for xstefank January 29, 2026 22:12
@metacosm metacosm self-assigned this Jan 29, 2026
Alternative without requiring collecting to a Map

Signed-off-by: Chris Laprun <metacosm@gmail.com>
@openshift-merge-robot openshift-merge-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jan 29, 2026
* @param <T> the type of HasMetadata objects
* @return a collector that produces a collection of deduplicated Kubernetes objects
*/
public static <T extends HasMetadata> Collector<T, ?, Collection<T>> latestDistinct() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wasn't this moved to ReconcileUtilsInternal

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we were to keep this implementation, this actually would be removed

Copy link
Collaborator

@csviri csviri left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made some minor comments, pls add unit tests! Otherwise looks great, thank you!!


default <R> Stream<R> getSecondaryResourcesAsStream(Class<R> expectedType) {
return getSecondaryResources(expectedType).stream();
return getSecondaryResourcesAsStream(expectedType, false);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here we could use the former implementation and call this in case in the new method the deduplication is false.

}

final var idToLatest = deduplicate ? new HashMap<ResourceID, String>() : null;
final var stream =
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As mentioned above for sake of simplicity/readbaility can if deduplicate is false could we just use the former implementation?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We could but this implementation avoids creating intermediary Streams, though I agree that it's slightly less readable. Let me see what I can do about that.

return controller.getEventSourceManager().getEventSourcesFor(expectedType).stream()
.map(es -> es.getSecondaryResources(primaryResource))
.flatMap(Set::stream);
public <R> Stream<R> getSecondaryResourcesAsStream(Class<R> expectedType, boolean deduplicate) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add comprehensive javadoc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support distinct if multiple ES for same type for getSecondaryResources()

5 participants