Skip to content

feat(cli): DSPX-2998 namespace flags for resource mapping commands#3576

Merged
alkalescent merged 5 commits into
mainfrom
DSPX-2998-rm-namespace-otdfctl
Jun 18, 2026
Merged

feat(cli): DSPX-2998 namespace flags for resource mapping commands#3576
alkalescent merged 5 commits into
mainfrom
DSPX-2998-rm-namespace-otdfctl

Conversation

@alkalescent

@alkalescent alkalescent commented Jun 5, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

Third PR in the stacked series for DSPX-2998. Adds otdfctl support for the new resource mapping namespace fields. Stacked on #3567 (service) — review/merge that first.

  • policy resource-mappings create / update: add --namespace-id and --namespace-fqn.
  • policy resource-mappings list: add --namespace-id / --namespace-fqn filters.
  • policy resource-mapping-groups list: add --namespace-id / --namespace-fqn filters.
  • Surface the owning namespace in command output (table + JSON).
  • Update the generated man-page docs for the new flags.

Migration note (AC3)

Migration support is delivered as a SQL backfill in the service PR (#3567), not via the otdfctl migrate graph framework. Rationale: RMGs are already mandatorily namespaced (nothing to migrate), and a grouped RM's owning namespace is fully determined by its group, so existing data just needs namespace_id backfilled from the group. The create-only graph framework (built for previously-global actions/SM/SCS/RR) is not a natural fit. This was confirmed as the chosen approach.

Checklist

  • I have added or updated unit tests
  • I have added or updated integration tests (if appropriate)
  • I have added or updated documentation

Testing Instructions

otdfctl policy resource-mappings create --help (shows the new flags); create/list mappings with --namespace-id / --namespace-fqn against a running platform.

Related

Summary by CodeRabbit

  • New Features
    • Added --namespace filtering to policy resource-mapping-groups list.
    • Added namespace scoping for policy resource-mappings create, list, update, and delete.
    • Updated policy resource-mappings list output to include namespace ownership (and adjusted columns accordingly).
  • Documentation
    • Updated manpages for resource-mapping-groups/list and resource-mappings/create/list/update to document the new --namespace flag.
  • Tests
    • Extended end-to-end tests to assert listed resource mappings include the expected namespace information.

@coderabbitai

coderabbitai Bot commented Jun 5, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b562266c-8c6f-4abc-b435-3421d5981215

📥 Commits

Reviewing files that changed from the base of the PR and between 65ae8b6 and 0b10cf9.

📒 Files selected for processing (8)
  • otdfctl/cmd/policy/resourceMappingGroups.go
  • otdfctl/cmd/policy/resourceMappings.go
  • otdfctl/docs/man/policy/resource-mapping-groups/list.md
  • otdfctl/docs/man/policy/resource-mappings/create.md
  • otdfctl/docs/man/policy/resource-mappings/list.md
  • otdfctl/docs/man/policy/resource-mappings/update.md
  • otdfctl/pkg/handlers/resourceMappingGroups.go
  • otdfctl/pkg/handlers/resourceMappings.go

📝 Walkthrough

Walkthrough

Handler methods for resource mappings and resource mapping groups are updated to accept context.Context and an optional namespace filter parameter, forwarding both into SDK requests. CLI commands for resource-mappings and resource-mapping-groups list gain --namespace flags, output tables are extended with namespace columns, man-page docs are updated, e2e tests verify namespace presence in list output, and Go module dependencies are bumped.

Changes

Namespace-scoped Resource Mappings and Groups

Layer / File(s) Summary
Handler signature updates: context and namespace params
otdfctl/pkg/handlers/resourceMappingGroups.go, otdfctl/pkg/handlers/resourceMappings.go
All resource mapping handler methods now accept context.Context; CreateResourceMapping, ListResourceMappings, UpdateResourceMapping, and ListResourceMappingGroups additionally accept a namespace string, which is converted to namespaceID and namespaceFqn via getNamespaceIDAndFQN() and forwarded into SDK requests.
CLI command wiring: namespace flags and context propagation
otdfctl/cmd/policy/resourceMappingGroups.go, otdfctl/cmd/policy/resourceMappings.go
create, update, list, get, and delete subcommands read the optional --namespace flag and pass cmd.Context() into all handler calls. Output tables for create, get, update, and delete gain Namespace Id and Namespace columns. List output replaces Group Id with Group Name and adds a Namespace column. Flag registrations added via injectNamespaceFlag() for create, list, and update subcommands.
Man-page docs for new namespace flags
otdfctl/docs/man/policy/resource-mapping-groups/list.md, otdfctl/docs/man/policy/resource-mappings/create.md, otdfctl/docs/man/policy/resource-mappings/list.md, otdfctl/docs/man/policy/resource-mappings/update.md
Adds --namespace filter flag (shorthand -s) with description and empty-string default to all affected man-page docs. Flag accepts namespace ID or FQN.
E2E test: namespace.id in list output
otdfctl/e2e/resource-mapping.bats
List resource mappings e2e test creates a grouped resource mapping and asserts that its .namespace.id in the JSON list response equals NS_ID.
Dependency version bumps
otdfctl/go.mod
Bumps github.com/opentdf/platform/protocol/go to v0.34.0, github.com/opentdf/platform/sdk to v0.22.0, google.golang.org/grpc to v1.81.1, and the indirect buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go dependency.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • opentdf/platform#3565: Adds namespace_id/namespace_fqn and ResourceMapping.namespace to the proto contracts that the handler code in this PR now wires through to SDK requests.
  • opentdf/platform#3567: Implements the server-side service/db/API logic for namespace-scoped resource mappings and groups, directly complementing this PR's CLI/handler wiring.

Suggested labels

size/s, docs

Suggested reviewers

  • c-r33d

Poem

🐇 Hoppity hop through the namespace maze,
Each mapping now scoped in newfangled ways!
--namespace flags appear with a cheer,
The context flows through, the code feels so clear.
With docs and e2e tests in the warren,
This rabbit's quite proud — namespace filtering has arrived!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately summarizes the main change: adding namespace flags to resource mapping CLI commands, which is the primary focus across all modified files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch DSPX-2998-rm-namespace-otdfctl

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist

Copy link
Copy Markdown
Contributor

Summary of Changes

Hello, 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 introduces namespace-aware resource mapping management to the otdfctl CLI. By adding support for namespace identifiers and fully qualified names (FQN) as both input flags and filter criteria, the changes allow for more granular control and visibility over resource mappings and their associated groups. These updates align the CLI with the backend service's resource mapping architecture.

Highlights

  • Namespace Support: Added support for --namespace-id and --namespace-fqn flags across resource mapping and resource mapping group commands.
  • Command Filtering: Enabled filtering by namespace in list commands for both resource mappings and resource mapping groups.
  • Output Enhancement: Updated command output to display the owning namespace in both table and JSON formats.
  • Documentation: Updated generated man-page documentation to reflect the new namespace-related flags.
New Features

🧠 You can now enable Memory (public preview) to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.


Commands grow with namespace in sight, Filtering resources with all of our might. Flags added to lists and to create, Keeping our mappings all perfectly straight.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions github-actions Bot added the size/m label Jun 5, 2026

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Code Review

This pull request adds support for namespace filtering via namespace-id and namespace-fqn flags across the resource mapping and resource mapping group commands, updating the CLI flags, documentation, and handler methods. The feedback recommends propagating context.Context from the CLI commands down to the SDK calls in CreateResourceMapping and UpdateResourceMapping instead of using context.Background(), which ensures proper cancellation, timeouts, and tracing.

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.

Comment thread otdfctl/pkg/handlers/resourceMappings.go Outdated
Comment thread otdfctl/pkg/handlers/resourceMappings.go Outdated
Comment thread otdfctl/cmd/policy/resourceMappings.go Outdated
Comment thread otdfctl/cmd/policy/resourceMappings.go Outdated
@github-actions

github-actions Bot commented Jun 5, 2026

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 179.760579ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 93.451584ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 661.906168ms
Throughput 151.08 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 44.0026865s
Average Latency 437.818892ms
Throughput 113.63 requests/second

@alkalescent alkalescent force-pushed the DSPX-2998-rm-namespace-service branch from 6f5d979 to 7080723 Compare June 8, 2026 15:15
@alkalescent alkalescent force-pushed the DSPX-2998-rm-namespace-otdfctl branch from 3927e2b to f8a39f1 Compare June 8, 2026 15:16
@github-actions

github-actions Bot commented Jun 8, 2026

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 158.876063ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 79.090633ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 413.48071ms
Throughput 241.85 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 42.889370473s
Average Latency 427.3675ms
Throughput 116.58 requests/second

@alkalescent alkalescent force-pushed the DSPX-2998-rm-namespace-service branch from 7080723 to 011c840 Compare June 15, 2026 17:02
Base automatically changed from DSPX-2998-rm-namespace-service to main June 17, 2026 15:01
- Add --namespace-id and --namespace-fqn to resource-mappings create and
  update, and as filters on resource-mappings list.
- Add --namespace-id and --namespace-fqn filters to resource-mapping-groups
  list.
- Surface the owning namespace in command output.

Stacked on the service PR (#3567).

Signed-off-by: Krish Suchak <suchak.krish@gmail.com>
Thread the command context through the resource mapping create/get/update/delete
handlers instead of context.Background(), matching the resource mapping group
handlers. Addresses review feedback.

Signed-off-by: Krish Suchak <suchak.krish@gmail.com>
… in otdfctl

Use the released protocol/go (with resource mapping namespace fields) and sdk.

Signed-off-by: Krish Suchak <suchak.krish@gmail.com>
@alkalescent alkalescent force-pushed the DSPX-2998-rm-namespace-otdfctl branch from f8a39f1 to e27b35b Compare June 17, 2026 20:28
@alkalescent alkalescent marked this pull request as ready for review June 17, 2026 20:31
@alkalescent alkalescent requested a review from a team as a code owner June 17, 2026 20:31
@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 173.462714ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 94.834809ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 454.066034ms
Throughput 220.23 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 43.358636878s
Average Latency 431.483715ms
Throughput 115.32 requests/second

The added Namespace column widened the resource-mappings list table past the
e2e terminal width, truncating the UUID columns the e2e test asserts on. Drop
the redundant group_id column (group_name still identifies the group; full id is
in get/--json) to make room for Namespace. Add a namespace assertion to the
list e2e test so the owning namespace is covered.

Signed-off-by: Krish Suchak <suchak.krish@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 190.785661ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 91.851032ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 448.869711ms
Throughput 222.78 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 43.40636896s
Average Latency 432.51394ms
Throughput 115.19 requests/second

@github-actions

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@otdfctl/go.mod`:
- Line 34: The `buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go`
dependency appears as a duplicate entry in the indirect dependencies section of
go.mod with the pseudo-version `v1.36.11-20260415201107-50325440f8f2.1`. Remove
this duplicate entry from the indirect section, and then run `go mod tidy` to
clean up the go.mod file and resolve any remaining dependency conflicts or
duplicates.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 52e65473-980e-42f2-97ba-a872601ff346

📥 Commits

Reviewing files that changed from the base of the PR and between da38619 and 65ae8b6.

⛔ Files ignored due to path filters (1)
  • otdfctl/go.sum is excluded by !**/*.sum
📒 Files selected for processing (10)
  • otdfctl/cmd/policy/resourceMappingGroups.go
  • otdfctl/cmd/policy/resourceMappings.go
  • otdfctl/docs/man/policy/resource-mapping-groups/list.md
  • otdfctl/docs/man/policy/resource-mappings/create.md
  • otdfctl/docs/man/policy/resource-mappings/list.md
  • otdfctl/docs/man/policy/resource-mappings/update.md
  • otdfctl/e2e/resource-mapping.bats
  • otdfctl/go.mod
  • otdfctl/pkg/handlers/resourceMappingGroups.go
  • otdfctl/pkg/handlers/resourceMappings.go

Comment thread otdfctl/go.mod
Comment thread otdfctl/docs/man/policy/resource-mapping-groups/list.md Outdated
c-r33d
c-r33d previously approved these changes Jun 18, 2026
Replace the --namespace-id/--namespace-fqn pairs on resource-mappings
create/update/list and resource-mapping-groups list with a single --namespace
(-s) flag that infers UUID vs FQN via getNamespaceIDAndFQN, matching the
actions/attributes/obligations convention. Addresses review feedback from
c-r33d. RMG create/update keep their pre-existing --namespace-id.

Signed-off-by: Krish Suchak <suchak.krish@gmail.com>
@github-actions

Copy link
Copy Markdown
Contributor
Benchmark results, click to expand

Benchmark authorization.GetDecisions Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 154.013785ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

Metric Value
Approved Decision Requests 1000
Denied Decision Requests 0
Total Time 85.223317ms

Benchmark Statistics

Name № Requests Avg Duration Min Duration Max Duration

Bulk Benchmark Results

Metric Value
Total Decrypts 100
Successful Decrypts 100
Failed Decrypts 0
Total Time 418.157414ms
Throughput 239.14 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 43.147826223s
Average Latency 429.803845ms
Throughput 115.88 requests/second

@github-actions

Copy link
Copy Markdown
Contributor

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

  • examples
  • otdfctl
  • sdk
  • service
  • lib/fixtures
  • tests-bdd

See the workflow run for details.

@alkalescent alkalescent enabled auto-merge June 18, 2026 15:55
@alkalescent alkalescent added this pull request to the merge queue Jun 18, 2026
Merged via the queue into main with commit beaaac5 Jun 18, 2026
40 checks passed
@alkalescent alkalescent deleted the DSPX-2998-rm-namespace-otdfctl branch June 18, 2026 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants