Skip to content

Conversation

@dmartinol
Copy link
Collaborator

@dmartinol dmartinol commented Sep 16, 2025

Fixes #1824

  • Filter by name with regexp
  • Filter by tags
  • Matching rules are explained in the doc.go file:
//  1. If exclude patterns/tags are specified and match -> exclude (precedence)
//  2. If include patterns/tags are specified and match -> include
//  3. If include patterns/tags are specified but no match -> exclude
//  4. If only exclude patterns/tags specified and no match -> include
//  5. If no filters specified -> include (default behavior)
//
// For a server to be included in the final registry, it must pass BOTH
// name and tag filtering (logical AND).
  • Refactored the sync.manager package to break down the individual steps and avoid the cyclomatic complexity linting issue
  • Updated examples with more relevant filters

dmartinol and others added 20 commits September 16, 2025 08:46
- ConfigMap source handler
- Basic unit tests

Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
- Updated tests and implementation to replace hardcoded "registry.json" key with ConfigMapSourceDataKey constant.
- Introduced ConfigMapStorageManager for managing registry data in ConfigMaps, including methods for storing, retrieving, and deleting data.
- Added comprehensive unit tests for the new storage manager functionality.

Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
- Updated test cases to replace hardcoded "registry.json" key with ConfigMapStorageDataKey constant.
- Ensured consistency in data handling across storage manager methods.

Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
- Updated ConfigMapSourceHandler to validate and parse registry data directly, removing legacy methods.
- Enhanced test cases to utilize a new TestRegistryBuilder for generating test data, improving readability and maintainability.
- Introduced new methods for handling registry data in a more structured way, including validation and conversion between formats.
- Updated SyncResult to encapsulate parsed registry data instead of raw data, streamlining the sync process.

Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
- Updated the storage manager implementation and tests to replace the hardcoded "registry-storage" component label with the new RegistryStorageComponent constant.
- Improved consistency and maintainability in label handling across the storage manager.

Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
- Introduced sync operation checks to determine if a sync is necessary before execution.
- Enhanced the ConfigMapSourceHandler to fetch registry data and validate source configurations more effectively.
- Improved test cases to reflect changes in method names and data handling.

Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
- Implement name filtering with glob pattern matching using filepath.Match
- Add tag filtering with exact string matching and precedence rules
- Create FilterService coordinator applying both name and tag filters
- Add comprehensive unit tests covering all filtering scenarios
- Enhance filter interfaces to return detailed inclusion/exclusion reasons
- Support include/exclude patterns with exclude taking precedence
- Add package documentation explaining filtering architecture and usage

Filtering system enables selective server inclusion from registry data
based on name patterns and tags, with detailed logging for debugging.

🤖 Generated with [Claude Code](https://claude.ai/code)

Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
Co-authored-by: Claude <noreply@anthropic.com>
Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
…cessing.

Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
…idation and support for name and tag filtering scenarios. Added expectedServerCount field to test cases to verify correct server inclusion based on filtering rules.

Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
@codecov
Copy link

codecov bot commented Sep 16, 2025

Codecov Report

❌ Patch coverage is 87.13235% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 46.55%. Comparing base (bd3474a) to head (c31607b).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
cmd/thv-operator/pkg/sync/manager.go 69.52% 25 Missing and 7 partials ⚠️
cmd/thv-operator/pkg/filtering/filter_service.go 97.47% 2 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1905      +/-   ##
==========================================
+ Coverage   46.22%   46.55%   +0.33%     
==========================================
  Files         217      220       +3     
  Lines       26980    27201     +221     
==========================================
+ Hits        12472    12664     +192     
- Misses      13553    13583      +30     
+ Partials      955      954       -1     

☔ View full report in Codecov by Sentry.
📢 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.

@dmartinol dmartinol requested a review from Copilot September 16, 2025 08:49
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR implements a comprehensive registry filtering system for MCPRegistry resources that allows filtering MCP servers by name patterns (using glob matching) and tags (using exact string matching). The system enables precise control over which servers are included in specific registries.

Key changes:

  • Added a complete filtering system with name and tag filtering capabilities
  • Refactored the sync manager to incorporate filtering into the registry synchronization process
  • Enhanced example configurations to demonstrate various filtering scenarios

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 1 comment.

File Description
examples/operator/mcp-registries/*.yaml Updated example configurations to showcase different filtering scenarios including tag-based, name pattern, and combined filtering
cmd/thv-operator/pkg/sync/manager.go Refactored sync manager to integrate filtering service and broke down sync process into smaller functions
cmd/thv-operator/pkg/sync/manager_test.go Added comprehensive tests for filtering functionality and improved test coverage
cmd/thv-operator/pkg/filtering/*.go New filtering package with name filter, tag filter, and filter service implementations

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@coveralls
Copy link
Collaborator

coveralls commented Sep 16, 2025

Coverage Status

coverage: 43.883% (+0.3%) from 43.591%
when pulling c31607b on dmartinol:registry_filter
into bd3474a on stacklok:main.

Copy link
Contributor

@jhrozek jhrozek left a comment

Choose a reason for hiding this comment

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

just a single question but ready to be merged.

jhrozek
jhrozek previously approved these changes Sep 16, 2025
Signed-off-by: Daniele Martinoli <dmartino@redhat.com>
@jhrozek jhrozek merged commit 395b6ba into stacklok:main Sep 16, 2025
15 checks passed
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.

[Kubernetes MCPRegistry] Source Filtering

3 participants