Skip to content

Commit

Permalink
use LabelSelectorMatcher for label filtering
Browse files Browse the repository at this point in the history
  • Loading branch information
aali309 authored and andrewazores committed Mar 20, 2024
1 parent a93f063 commit ffc897b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/io/cryostat/graphql/EnvironmentNodes.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import java.util.Objects;

import io.cryostat.discovery.DiscoveryNode;
import io.cryostat.graphql.matchers.LabelSelectorMatcher;

import io.smallrye.graphql.api.Nullable;
import org.eclipse.microprofile.graphql.Description;
Expand Down Expand Up @@ -67,7 +68,11 @@ private static boolean matchesFilter(DiscoveryNode node, EnvironmentNodeFilterIn
boolean matchesNames = filter.names == null || filter.names.contains(node.name);
boolean matchesLabels =
filter.labels == null
|| filter.labels.stream().allMatch(label -> node.labels.containsKey(label));
|| filter.labels.stream()
.allMatch(
label ->
LabelSelectorMatcher.parse(label)
.test(node.labels));
boolean matchesNodeType = filter.nodeType == null || filter.nodeType.equals(node.nodeType);

return matchesId && matchesName && matchesNames && matchesLabels && matchesNodeType;
Expand Down

0 comments on commit ffc897b

Please sign in to comment.