Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,15 @@ public static ResourceID fromResource(HasMetadata resource) {
resource.getMetadata().getNamespace());
}

public static Optional<ResourceID> fromFirstOwnerReference(HasMetadata dependentResource) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

It'd be better if you'd use the implementation from the dependent resources branch: https://github.com/java-operator-sdk/java-operator-sdk/pull/785/files#diff-5166f926d491fa8bc37664176eb65ecb8dc051b8db0e3d3771fb817a1fbd462dR70-R80 so that merging later will be easier.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

good point, changed

var ownerReferences = dependentResource.getMetadata().getOwnerReferences();
if (ownerReferences == null || ownerReferences.isEmpty()) {
return Optional.empty();
}
return Optional.of(new ResourceID(ownerReferences.get(0).getName(),
dependentResource.getMetadata().getNamespace()));
}

private final String name;
private final String namespace;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,15 +52,8 @@ public List<EventSource> prepareEventSources(EventSourceContext<Tomcat> context)
.runnableInformer(0);

return List.of(new InformerEventSource<>(
deploymentInformer, d -> {
var ownerReferences = d.getMetadata().getOwnerReferences();
if (!ownerReferences.isEmpty()) {
return Set.of(new ResourceID(ownerReferences.get(0).getName(),
d.getMetadata().getNamespace()));
} else {
return EMPTY_SET;
}
}));
deploymentInformer,
d -> ResourceID.fromFirstOwnerReference(d).map(r -> Set.of(r)).orElse(EMPTY_SET)));
}

@Override
Expand Down