Skip to content

[match]: Add glob matcher for routing rules#52

Merged
pseudomuto merged 1 commit into
mainfrom
wildcard_match
Jul 13, 2026
Merged

[match]: Add glob matcher for routing rules#52
pseudomuto merged 1 commit into
mainfrom
wildcard_match

Conversation

@pseudomuto

Copy link
Copy Markdown
Collaborator

Routing rules (RFC #32) match namespaces and metadata values using simple globs: exact, prefix (foo*), suffix (*foo), and contains (*foo*). This adds a small, dependency-free pkg/match that compiles a pattern once and matches against it.

The implementation deliberately supports only those four forms and rejects an interior "" (e.g., "ab") at compile time, so a malformed pattern fails fast at config load rather than silently matching the wrong thing. A general globber (e.g. path.Match, regexp) was avoided on purpose: those assign meaning to "?", "[]", "", and treat "/" as a separator, which would change behaviour for operator-authored patterns and arbitrary metadata values.

@pseudomuto pseudomuto requested a review from Copilot June 30, 2026 19:18
@pseudomuto pseudomuto requested a review from a team as a code owner June 30, 2026 19:18
@codecov-commenter

codecov-commenter commented Jun 30, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 94.59459% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.44%. Comparing base (ad23f91) to head (c236f2a).

Files with missing lines Patch % Lines
pkg/match/match.go 94.59% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #52      +/-   ##
==========================================
+ Coverage   85.12%   85.44%   +0.32%     
==========================================
  Files          33       34       +1     
  Lines        1042     1079      +37     
==========================================
+ Hits          887      922      +35     
- Misses        131      133       +2     
  Partials       24       24              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

Adds a small pkg/match helper to compile and apply a constrained “glob” syntax used by routing rules (namespace/metadata matching), intentionally avoiding full glob/regexp semantics.

Changes:

  • Introduces pkg/match.Matcher with Compile / MustCompile and Match for literal/prefix/suffix/contains matching.
  • Adds unit tests covering supported forms, match-all patterns, and rejection of embedded *.
  • Adds package-level documentation describing the supported pattern forms.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

File Description
pkg/match/match.go Implements the compiled matcher, pattern compilation/validation, and matching logic.
pkg/match/match_test.go Adds tests for matcher behavior and invalid pattern rejection.
pkg/match/doc.go Documents the supported matching forms for operator-authored patterns.

Comment thread pkg/match/doc.go Outdated
Comment thread pkg/match/match_test.go Outdated
Routing rules (RFC #32) match namespaces and metadata values using
simple globs: exact, prefix (foo*), suffix (*foo), and contains (*foo*).
This adds a small, dependency-free pkg/match that compiles a pattern
once and matches against it.

The implementation deliberately supports only those four forms and
rejects an interior "*" (e.g. "a*b") at compile time, so a malformed
pattern fails fast at config-load rather than silently matching the
wrong thing. A general globber (e.g. path.Match, regexp) was avoided on
purpose: those assign meaning to "?", "[]", "\", and treat "/" as a
separator, which would change behavior for operator-authored patterns
and arbitrary metadata values.
@pseudomuto pseudomuto merged commit cbd5efa into main Jul 13, 2026
6 checks passed
@pseudomuto pseudomuto deleted the wildcard_match branch July 13, 2026 13:48
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.

3 participants