Skip to content

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

Draft
alkalescent wants to merge 1 commit into
DSPX-2998-rm-namespace-servicefrom
DSPX-2998-rm-namespace-otdfctl
Draft

feat(cli): DSPX-2998 namespace flags for resource mapping commands#3576
alkalescent wants to merge 1 commit into
DSPX-2998-rm-namespace-servicefrom
DSPX-2998-rm-namespace-otdfctl

Conversation

@alkalescent
Copy link
Copy Markdown
Contributor

@alkalescent alkalescent commented Jun 5, 2026

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

- 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>
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 5, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 7df3b01a-a486-4ff0-abb6-6b46914031cb

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 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
Copy link
Copy Markdown
Contributor

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

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.


// Creates and returns the created resource mapping
func (h *Handler) CreateResourceMapping(attributeID string, terms []string, grpID string, metadata *common.MetadataMutable) (*policy.ResourceMapping, error) {
func (h *Handler) CreateResourceMapping(attributeID string, terms []string, grpID, namespaceID, namespaceFqn string, metadata *common.MetadataMutable) (*policy.ResourceMapping, error) {
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.

medium

In Go, it is a best practice to propagate context.Context to downstream handlers and SDK calls rather than using context.Background(). This enables proper cancellation, timeouts, and tracing.

Please update the signature of CreateResourceMapping to accept ctx context.Context as the first parameter, and use it in the CreateResourceMapping SDK call on the next line.

Suggested change
func (h *Handler) CreateResourceMapping(attributeID string, terms []string, grpID, namespaceID, namespaceFqn string, metadata *common.MetadataMutable) (*policy.ResourceMapping, error) {
func (h *Handler) CreateResourceMapping(ctx context.Context, attributeID string, terms []string, grpID, namespaceID, namespaceFqn string, metadata *common.MetadataMutable) (*policy.ResourceMapping, error) {

// TODO: verify updation behavior
// Updates and returns the updated resource mapping
func (h *Handler) UpdateResourceMapping(id string, attrValueID string, grpID string, terms []string, metadata *common.MetadataMutable, behavior common.MetadataUpdateEnum) (*policy.ResourceMapping, error) {
func (h *Handler) UpdateResourceMapping(id, attrValueID, grpID, namespaceID, namespaceFqn string, terms []string, metadata *common.MetadataMutable, behavior common.MetadataUpdateEnum) (*policy.ResourceMapping, error) {
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.

medium

In Go, it is a best practice to propagate context.Context to downstream handlers and SDK calls rather than using context.Background(). This enables proper cancellation, timeouts, and tracing.

Please update the signature of UpdateResourceMapping to accept ctx context.Context as the first parameter, and use it in the UpdateResourceMapping SDK call on the next line.

Suggested change
func (h *Handler) UpdateResourceMapping(id, attrValueID, grpID, namespaceID, namespaceFqn string, terms []string, metadata *common.MetadataMutable, behavior common.MetadataUpdateEnum) (*policy.ResourceMapping, error) {
func (h *Handler) UpdateResourceMapping(ctx context.Context, id, attrValueID, grpID, namespaceID, namespaceFqn string, terms []string, metadata *common.MetadataMutable, behavior common.MetadataUpdateEnum) (*policy.ResourceMapping, error) {

metadataLabels = c.Flags.GetStringSlice("label", metadataLabels, cli.FlagsStringSliceOptions{Min: 0})

resourceMapping, err := h.CreateResourceMapping(attrID, terms, grpID, getMetadataMutable(metadataLabels))
resourceMapping, err := h.CreateResourceMapping(attrID, terms, grpID, nsID, nsFqn, getMetadataMutable(metadataLabels))
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.

medium

Pass the command's context (cmd.Context()) to the updated CreateResourceMapping handler method to support proper context propagation.

Suggested change
resourceMapping, err := h.CreateResourceMapping(attrID, terms, grpID, nsID, nsFqn, getMetadataMutable(metadataLabels))
resourceMapping, err := h.CreateResourceMapping(cmd.Context(), attrID, terms, grpID, nsID, nsFqn, getMetadataMutable(metadataLabels))

metadataLabels = c.Flags.GetStringSlice("label", metadataLabels, cli.FlagsStringSliceOptions{Min: 0})

resourceMapping, err := h.UpdateResourceMapping(id, attrValueID, grpID, terms, getMetadataMutable(metadataLabels), getMetadataUpdateBehavior())
resourceMapping, err := h.UpdateResourceMapping(id, attrValueID, grpID, nsID, nsFqn, terms, getMetadataMutable(metadataLabels), getMetadataUpdateBehavior())
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.

medium

Pass the command's context (cmd.Context()) to the updated UpdateResourceMapping handler method to support proper context propagation.

Suggested change
resourceMapping, err := h.UpdateResourceMapping(id, attrValueID, grpID, nsID, nsFqn, terms, getMetadataMutable(metadataLabels), getMetadataUpdateBehavior())
resourceMapping, err := h.UpdateResourceMapping(cmd.Context(), id, attrValueID, grpID, nsID, nsFqn, terms, getMetadataMutable(metadataLabels), getMetadataUpdateBehavior())

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

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

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Jun 5, 2026

⚠️ Govulncheck found vulnerabilities ⚠️

The following modules have known vulnerabilities:

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

See the workflow run for details.

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.

1 participant