Support LDAP Nested Query - #321
Conversation
Signed-off-by: Abhidas747 <abhishek.das747@gmail.com>
Summary of ChangesHello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! This pull request enhances the LDAP query capabilities of the Group CRD by enabling nested sub-queries. This allows users to define more expressive, compound boolean conditions (e.g., combining multiple OR and AND operations) that were previously limited to a flat filter structure. The changes include updates to the API schema, controller logic for handling recursive query structures, and extensive testing to ensure reliability and backward compatibility. Highlights
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. LDAP filters, once so flat, Now grow branches, fancy that! Nested logic, deep and wide, With nowhere for the groups to hide. Footnotes
|
There was a problem hiding this comment.
Code Review
This pull request introduces support for nested LDAP queries in the Usernaut operator. It defines new nested query structures (LDAPSubQuery, LDAPLeafQuery, and LDAPLeafSubQuery) in the API, updates the CRD schemas, and refactors the controller and LDAP client to recursively parse, build, and handle manager filters within these nested query trees. Comprehensive unit tests and sample configurations are also added. The review feedback focuses on strengthening the CRD validation rules to prevent empty filters or queries from bypassing validation, and suggests minor code improvements for consistency and better serialization in the controller's helper functions.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
…f filters or queries is specified and non-empty. Signed-off-by: Abhidas747 <abhishek.das747@gmail.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for nested LDAP queries in the group controller by defining new nested query types (LDAPSubQuery, LDAPLeafQuery, LDAPLeafSubQuery) and updating the CRD schema, deepcopy functions, and query builder to recursively process and validate these nested structures. It also refactors the controller's manager filter detection and replacement logic to support recursive traversal, backed by new unit tests. The review feedback highlights several violations of the repository style guide where functions return nil instead of empty slices when handling empty results, and suggests returning empty slices/maps instead.
Important
The consumer version of Gemini Code Assist on GitHub is being sunset. Starting June 18, 2026, new organization installations will be blocked, and all code review activity will officially cease on July 17, 2026.
For more details on the timeline and next steps, please review the Help Documentation.
Signed-off-by: Abhidas747 <abhishek.das747@gmail.com>
Signed-off-by: Abhidas747 <abhishek.das747@gmail.com>
Signed-off-by: Abhidas747 <abhishek.das747@gmail.com>
| // +optional | ||
| // +kubebuilder:validation:Schemaless | ||
| // +kubebuilder:pruning:PreserveUnknownFields | ||
| LDAPQuery *LDAPQuery `json:"ldap_query,omitempty"` |
There was a problem hiding this comment.
is it possible to have some validation here that checks that if key/criteria etc are provided then ldap_query is not supported? and vice versa?
There was a problem hiding this comment.
@Abhidas747 can we add test for that vaalidation?
There was a problem hiding this comment.
Added test for this validation.
…teria/value and nested LDAP queries. Signed-off-by: Abhidas747 <abhishek.das747@gmail.com>
…riteria/value and ldap_query Signed-off-by: Abhidas747 <abhishek.das747@gmail.com>
2b9d80f to
f9bf67a
Compare
Signed-off-by: Abhidas747 <abhishek.das747@gmail.com>
Changes
📝 Description
What changed?
The
ldap_queryin Group CRD previously supported only a flat list of filters under a single boolean operator. This PR introduces aqueriesfield that allows nesting sub-queries with their own operators, enabling compound boolean logic (e.g., OR across title patterns AND-ed with global exclusions). The nesting is implemented as a fixed-depth typed hierarchy (4 levels:LDAPQuery→LDAPSubQuery→LDAPLeafQuery→LDAPLeafSubQuery) with full CRD schema validation at each level.Why is this change needed?
Real-world LDAP-driven consumer group policies require nested OR + AND combinations (e.g., "(engineers OR developers) AND (manager=X OR manager=Y) AND NOT external"). The previous flat filter model could not express these compound conditions.
Dependencies
🧪 Testing
Test Coverage
pkg/clients/ldap/query_test.gofor all nesting scenarios (4-level nesting, queries-only, mixed filters+queries, invalid nested operators, empty leaf filters).internal/controller/group_controller_manager_query_test.gofor manager filter detection, UID extraction, filter replacement, and deduplication across nested structures.Performance Impact
🚀 Deployment
Deploy Steps
make installor deploy updated CRD YAML)Prerequisites
queriesfield is createdPost-Deployment Monitoring
Rollback Plan
filtersremain unaffectedDetails:
filterswork unchanged)⚙️ Configuration Changes
✅ Developer Checklist