Skip to content

feat(labeler): support comma-separated JSONPath queries in DefaultQuery#429

Closed
browdues wants to merge 1 commit into
mainfrom
feat/labeler-update
Closed

feat(labeler): support comma-separated JSONPath queries in DefaultQuery#429
browdues wants to merge 1 commit into
mainfrom
feat/labeler-update

Conversation

@browdues
Copy link
Copy Markdown
Contributor

Allows comma-separated JSONPath expressions in LabelConfig.DefaultQuery.

Each expression is evaluated independently and results are joined with -.

This enables K8s-style labels like namespace-name from a single query string: $.metadata.namespace,$.metadata.name. Cluster-scoped resources (no namespace) naturally produce just the name since the missing field returns no result and is skipped

Previously, DefaultQuery only accepted a single JSONPath. Plugins needing multi-field labels had no option — K8s resources collided when a Service and its auto-created Endpoints shared the same name.

  • 2 new tests (comma-separated with namespace+name, single-field fallback)
  • All 15 labeler tests pass

@browdues browdues requested a review from JeroenSoeters April 22, 2026 21:47
Copy link
Copy Markdown
Collaborator

@JeroenSoeters JeroenSoeters left a comment

Choose a reason for hiding this comment

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

I'd push back on this:

The field is documented as a JSONPath query expression, after this PR, it no longer is one. Comma-separated queries are a custom invention layered on top, this means:

  • the semantics become somewhat surprising, everyone reading $.metadata.namespace,$.metadata.name would reasonably try to validate it as a JSONPath expression and be confused when it fails.
  • JSONPath queries themselves can contain commas, strings.Split(query, ",") would break those

Also JSONPath already has a union operator. The standard syntax $['metadata']['namespace','name'] selects multiple fields. I believe we might be doing this already in AWS. The only restriction is that this operator can only select keys from the same top-level parent, it cannot select keys from different part of the tree. If we need this I suggest we switch to a slice on the interface DefaultQueries []string. It looks though that we might get away with the union operator here?

@browdues browdues closed this Apr 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants