-
Notifications
You must be signed in to change notification settings - Fork 31
feat(graphql): implement k8s-style label selectors #872
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(graphql): implement k8s-style label selectors #872
Conversation
7220c2c
to
e1857df
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The label equality matchers are working well with both labels and annotation filters. Just had a question about the set matchers
src/main/java/io/cryostat/net/web/http/api/beta/graph/labels/SetMatcher.java
Show resolved
Hide resolved
src/main/java/io/cryostat/net/web/http/api/beta/graph/labels/LabelSelectorMatcher.java
Show resolved
Hide resolved
694d420
to
670e06d
Compare
With the latest commit you can perform a query like: query {
environmentNodes(filter: { name: "JDP" }) {
name
nodeType
descendantTargets (filter: { annotations: ["PORT in (9091, 9096)", "env != production"] }) {
target {
alias
annotations {
cryostat
}
}
}
}
} GraphQL also seems to support a sort of "bare singleton" for lists, so you can also do: query {
environmentNodes(filter: { name: "JDP" }) {
name
nodeType
descendantTargets (filter: { annotations: "PORT in (9091, 9096)" } ) {
target {
alias
annotations {
cryostat
}
}
}
}
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good!
Looking ahead, will there be other documentation (eg on HTTP_API or cryostat.io) for these 2.1 GraphQL features besides the blog posts?
I think a general description of the GraphQL endpoint in |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Whoops, just saw this now
src/test/java/io/cryostat/net/web/http/api/beta/graph/labels/LabelSelectorMatcherTest.java
Outdated
Show resolved
Hide resolved
* feat(graphql): implement k8s-style label selectors * apply spotless formatting * handle null expression string * remove unused input type * hook label selector matcher into fetchers * hook label selector matcher into annotations on target fetchers * do not include parens in values character set * relax regexes to allow non-whitespace characters * fixup! relax regexes to allow non-whitespace characters * exercise set membership a bit more * support conjunction of filter/annotation expressions by GraphQL list * remove disabled/unsupported test (cherry picked from commit a957d56)
* feat(graphql): implement k8s-style label selectors * apply spotless formatting * handle null expression string * remove unused input type * hook label selector matcher into fetchers * hook label selector matcher into annotations on target fetchers * do not include parens in values character set * relax regexes to allow non-whitespace characters * fixup! relax regexes to allow non-whitespace characters * exercise set membership a bit more * support conjunction of filter/annotation expressions by GraphQL list * remove disabled/unsupported test (cherry picked from commit a957d56) Co-authored-by: Andrew Azores <[email protected]>
Closes #846
Closes #825
Closes #822
Closes #821
Closes #820
This adds
labels
to GraphQL query filters for nodes in the deployment tree and for recordings, as well asannotations
to query filters on target nodes. Forannotations
the Cryostat-generated annotations and the platform-provided annotations are merged together into one map. Both thelabels
andannotations
query fields are optional, and can be given a Kubernetes label selector expression to match against the labels or annotations maps on the objects being queried.