feat: add reserved --filter root value for root-level-only config#48
Open
piotrek-janus wants to merge 2 commits into
Open
feat: add reserved --filter root value for root-level-only config#48piotrek-janus wants to merge 2 commits into
piotrek-janus wants to merge 2 commits into
Conversation
Add a reserved `root` value to the --filter flag (pull, push, diff) that selects only root-level tenant/workspace config, excluding nested resource collections (clients, idps, pools, policies, etc.). `root` is composable with resource names, e.g. `--filter root,clients`, and resolves per context: FilterPatch now takes the set of known collection keys (TenantCollectionKeys / ServerCollectionKeys) and treats every other top-level key as root-level. Not a breaking change: `root` was previously a no-op filter value and all existing filter tokens are unaffected.
…tic list Replace the hand-maintained TenantCollectionKeys/ServerCollectionKeys exclusion lists with root-field sets derived via reflection from the models the storage layer already serializes the root tenant/server file into (smodels.Tenant and smodels.ServerDump, with nested dependencies stripped). `--filter root` now keeps exactly the top-level keys defined on those root models, so new root fields added upstream are picked up automatically with no list to keep in sync. FilterPatch takes the root-key set instead of a collection exclusion list.
There was a problem hiding this comment.
Pull request overview
This PR adds a reserved root token for the --filter flag so users can select only the root-level tenant/workspace configuration (excluding nested collections), with the root field set derived automatically from the storage-layer models.
Changes:
- Added
rootfiltering support toFilterPatchusing model-reflection-derived root key sets. - Updated storage/client call sites for the new
FilterPatch(..., rootKeys)signature. - Extended filter tests and updated CLI help text to document
--filter rootusage.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| internal/cac/utils/model.go | Adds RootFilter, derives root key sets via reflection, and updates FilterPatch to support root-only selection. |
| internal/cac/utils/model_test.go | Extends TestFilterPatch with root-only and root+collection scenarios for tenant/workspace contexts. |
| internal/cac/storage/tenant_storage.go | Passes utils.TenantRootKeys into FilterPatch for tenant reads. |
| internal/cac/storage/tenant_storage_test.go | Updates test filtering call to pass tenant root keys. |
| internal/cac/storage/server_storage.go | Passes utils.ServerRootKeys into FilterPatch for workspace/server reads. |
| internal/cac/storage/server_storage_test.go | Updates test filtering call to pass server root keys. |
| internal/cac/client/tenant_client.go | Passes utils.TenantRootKeys into FilterPatch for tenant client reads. |
| internal/cac/client/client.go | Passes utils.ServerRootKeys into FilterPatch for workspace client reads. |
| cmd/push.go | Documents --filter root and --filter root,clients in CLI help text. |
| cmd/pull.go | Documents --filter root and --filter root,clients in CLI help text. |
| cmd/diff.go | Documents --filter root and --filter root,clients in CLI help text. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
ikawalec
approved these changes
Jul 6, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds a reserved
rootvalue to the--filterflag (pull,push,diff) that selects only root-level tenant/workspace config, excluding all nested sub-resources (clients, idps, pools, policies, schemas, themes, servers, etc.).Previously there was no way to restrict a filter to an object's own root-level settings — users had to enumerate every root field by hand.
Behavior
--filter root→ keep only root-level fields.--filter root,clients→ root fields plus theclientscollection.How "root" is defined (model-derived, no maintenance)
The set of root fields is derived via reflection from the models the storage layer already serializes the root file into —
smodels.Tenantfor the tenant andsmodels.ServerDumpfor a workspace (both are the config with nested dependencies stripped).--filter rootkeeps exactly the top-level keys defined on those models.This means new root fields added upstream are picked up automatically — there is no hand-maintained collection/root list to keep in sync.
FilterPatchtakes the derived root-key set (utils.TenantRootKeys/utils.ServerRootKeys).Not a breaking change
rootwas previously a no-op filter value (no resource is namedroot, so it matched nothing and returned an empty patch). All existing filter tokens behave identically — therootbranch is only entered for the exactroottoken. TheFilterPatchsignature change is internal only.Tests
TestFilterPatchwith root-only, root+collection, tenant-context, and empty-result cases (exercising the reflection-derived key sets).go vetand build clean.