From ba3cd8a07e460127bf9c7327ef6d53be24f5846c Mon Sep 17 00:00:00 2001 From: Atif Ali Date: Thu, 29 Feb 2024 10:06:33 -0500 Subject: [PATCH] use LabelSelectorMatcher for label filtering --- src/main/java/io/cryostat/graphql/EnvironmentNodes.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/main/java/io/cryostat/graphql/EnvironmentNodes.java b/src/main/java/io/cryostat/graphql/EnvironmentNodes.java index 84329a967..bb0d0422e 100644 --- a/src/main/java/io/cryostat/graphql/EnvironmentNodes.java +++ b/src/main/java/io/cryostat/graphql/EnvironmentNodes.java @@ -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; @@ -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;