Skip to content

feat(cli): add dynamic value mapping CRUD commands and e2e tests - #3768

Merged
alkalescent merged 3 commits into
mainfrom
DSPX-4096-otdfctl-dynamic-value-mappings
Jul 27, 2026
Merged

feat(cli): add dynamic value mapping CRUD commands and e2e tests#3768
alkalescent merged 3 commits into
mainfrom
DSPX-4096-otdfctl-dynamic-value-mappings

Conversation

@alkalescent

@alkalescent alkalescent commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Proposed Changes

  • Add a policy dynamic-value-mappings command group to otdfctl (aliases dvm, dynamic-value-mapping) with create, get, list, update, and delete, mirroring the subject-mappings pattern. Wraps the DynamicValueMapping SDK client with a new handler, cobra commands, and man docs.
  • Validate the resolver operator client-side (only IN / IN_CONTAINS; reject NOT_IN and unspecified), require exactly one of --attribute-definition-id / --attribute-definition-fqn, and require --selector and --operator together on update.
  • Add an end-to-end bats suite (otdfctl/e2e/dynamic-value-mapping.bats) covering CRUD (table + --json), static-gate create, namespace id/fqn, sort/filter, and error/rejection cases (NOT_IN, missing operator/definition/action, HIERARCHY definition, value-subject-mapping coexistence).

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

  • cd otdfctl && golangci-lint run ./... && go test ./...
  • Start and provision a local platform, then run the e2e suite:
    cd otdfctl && make test-bats (or bats ./e2e/dynamic-value-mapping.bats).
    Verified locally: all 13 tests pass against a live platform.

Summary by CodeRabbit

  • New Features
    • Added CLI support to create, retrieve, list, update, and delete dynamic value mappings.
    • Added filtering, pagination, sorting, metadata labels, resolver configuration, actions, and optional subject-condition gates.
    • Added validation for supported operators and required option combinations.
  • Documentation
    • Added command reference pages with usage, flags, constraints, and examples.
  • Tests
    • Added end-to-end coverage for lifecycle operations, validation, filtering, sorting, and JSON/table output.

Signed-off-by: Krish Suchak <suchak.krish@gmail.com>
Signed-off-by: Krish Suchak <suchak.krish@gmail.com>
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@alkalescent, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 24 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 70145b91-b2b1-4fc2-b9c3-031ae535ac5f

📥 Commits

Reviewing files that changed from the base of the PR and between e520761 and 1b8b2f9.

📒 Files selected for processing (3)
  • otdfctl/cmd/policy/dynamicValueMappings.go
  • otdfctl/docs/man/policy/dynamic-value-mappings/create.md
  • otdfctl/e2e/dynamic-value-mapping.bats
📝 Walkthrough

Walkthrough

Adds SDK-backed handlers and a Cobra command group for creating, retrieving, listing, updating, and deleting dynamic value mappings, with documentation and end-to-end coverage for validation and lifecycle behavior.

Changes

Dynamic Value Mapping CLI

Layer / File(s) Summary
SDK handler operations
otdfctl/pkg/handlers/dynamicvaluemappings.go
Adds handler methods for dynamic value mapping CRUD operations, filtering, pagination, sorting, namespace resolution, and metadata updates.
CLI command flow
otdfctl/cmd/policy/dynamicValueMappings.go, otdfctl/cmd/policy/policy.go
Registers the command group and implements flag validation, action/operator parsing, CRUD handlers, table output, pagination, confirmation, and metadata handling.
Command documentation
otdfctl/docs/man/policy/dynamic-value-mappings/*
Documents dynamic value mapping semantics, supported operators, constraints, examples, and CRUD command flags.
End-to-end lifecycle coverage
otdfctl/e2e/dynamic-value-mapping.bats
Tests creation, validation failures, filtering, sorting, retrieval, updates, and deletion using provisioned policy fixtures.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant User
  participant CobraCommands
  participant Handler
  participant DynamicValueMappingSDK
  User->>CobraCommands: invoke dynamic value mapping command
  CobraCommands->>Handler: validate inputs and call operation
  Handler->>DynamicValueMappingSDK: send CRUD request
  DynamicValueMappingSDK-->>Handler: return mapping response
  Handler-->>CobraCommands: return mapping data
  CobraCommands-->>User: render table or JSON
Loading

Suggested labels: comp:policy, comp:sdk, docs, size/m

Poem

A rabbit typed commands with a hop and a cheer,
Mappings CRUD danced from far to near.
Selectors matched and actions took flight,
Tests checked each burrow from morning to night.
“IN” and “IN_CONTAINS” made the garden glow!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 50.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: new dynamic value mapping CLI CRUD commands plus e2e tests.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch DSPX-4096-otdfctl-dynamic-value-mappings

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.

@alkalescent
alkalescent marked this pull request as ready for review July 22, 2026 05:02
@alkalescent
alkalescent requested a review from a team as a code owner July 22, 2026 05:02
@gemini-code-assist

Copy link
Copy Markdown
Contributor

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@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 212.845281ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

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

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 425.439964ms
Throughput 235.05 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 49.481285138s
Average Latency 491.846415ms
Throughput 101.05 requests/second

@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: 6

🤖 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/cmd/policy/dynamicValueMappings.go`:
- Around line 145-166: Update the validation block in the command handler to
reject requests when both existingSCSID and newScsJSON are provided, using the
same mutual-exclusivity pattern and cli.ExitWithError as the
attribute-definition checks. Preserve requests where either value is provided
alone or both are omitted.

In `@otdfctl/docs/man/policy/dynamic-value-mappings/create.md`:
- Around line 59-60: Insert a blank line immediately before each of the three
opening fenced code examples in the dynamic value mappings documentation,
including the examples near the referenced sections, to satisfy Markdownlint
MD031.
- Around line 24-25: Update the --action option description in the create
dynamic value mapping documentation to state that at least one action is
required. Keep the existing action examples and align the wording with the
validation enforced by policyCreateDynamicValueMapping.

In `@otdfctl/e2e/dynamic-value-mapping.bats`:
- Line 128: Update the dynamic value mapping create invocation in the affected
test to use the singular dynamic-value-mapping command alias instead of dvm,
while preserving all existing arguments and assertions so the advertised alias
is exercised.
- Around line 223-229: Extend the “Delete dynamic value mapping” test after the
existing successful delete assertions by calling run_otdfctl_dvm get --id
"$to_delete" and asserting failure. Keep the current deletion-success and ID
checks, and verify the deleted mapping is no longer retrievable.
- Around line 11-19: Update every fixture-provisioning command in the test,
including the namespace and dynamic-value mapping setup sites, to run the
otdfctl command separately from jq. Use run and assert_success before parsing
output, then extract the returned ID and validate it is non-empty before
continuing, so failed CLI commands cannot be masked by jq or produce misleading
assertions.
🪄 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: 3caca32b-e590-45b2-9832-44215199dd47

📥 Commits

Reviewing files that changed from the base of the PR and between 5bae1eb and e520761.

📒 Files selected for processing (10)
  • otdfctl/cmd/policy/dynamicValueMappings.go
  • otdfctl/cmd/policy/policy.go
  • otdfctl/docs/man/policy/dynamic-value-mappings/_index.md
  • otdfctl/docs/man/policy/dynamic-value-mappings/create.md
  • otdfctl/docs/man/policy/dynamic-value-mappings/delete.md
  • otdfctl/docs/man/policy/dynamic-value-mappings/get.md
  • otdfctl/docs/man/policy/dynamic-value-mappings/list.md
  • otdfctl/docs/man/policy/dynamic-value-mappings/update.md
  • otdfctl/e2e/dynamic-value-mapping.bats
  • otdfctl/pkg/handlers/dynamicvaluemappings.go

Comment thread otdfctl/cmd/policy/dynamicValueMappings.go
Comment thread otdfctl/docs/man/policy/dynamic-value-mappings/create.md Outdated
Comment thread otdfctl/docs/man/policy/dynamic-value-mappings/create.md
Comment thread otdfctl/e2e/dynamic-value-mapping.bats
Comment thread otdfctl/e2e/dynamic-value-mapping.bats Outdated
Comment thread otdfctl/e2e/dynamic-value-mapping.bats
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 170.043092ms

Benchmark authorization.v2.GetMultiResourceDecision Results:

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

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 361.529967ms
Throughput 276.60 requests/second

TDF3 Benchmark Results:

Metric Value
Total Requests 5000
Successful Requests 5000
Failed Requests 0
Concurrent Requests 50
Total Time 44.647006614s
Average Latency 445.088847ms
Throughput 111.99 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.

Comment thread otdfctl/docs/man/policy/dynamic-value-mappings/create.md
Comment thread otdfctl/docs/man/policy/dynamic-value-mappings/create.md
Comment thread otdfctl/docs/man/policy/dynamic-value-mappings/get.md
Comment thread otdfctl/docs/man/policy/dynamic-value-mappings/delete.md
Comment thread otdfctl/cmd/policy/dynamicValueMappings.go
Comment thread otdfctl/e2e/dynamic-value-mapping.bats
Comment thread otdfctl/docs/man/policy/dynamic-value-mappings/list.md
@alkalescent
alkalescent added this pull request to the merge queue Jul 27, 2026
Merged via the queue into main with commit aecd265 Jul 27, 2026
45 checks passed
@alkalescent
alkalescent deleted the DSPX-4096-otdfctl-dynamic-value-mappings branch July 27, 2026 19:56
khvirtru pushed a commit to khvirtru/platform that referenced this pull request Aug 5, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.36.0](opentdf/platform@otdfctl/v0.35.0...otdfctl/v0.36.0)
(2026-08-04)


### ⚠ BREAKING CHANGES

* **policy:** GetPC does not respect manager field.
([opentdf#3752](opentdf#3752))

### Features

* **authz:** dynamic value mapping and direct entitlement e2e coverage
([opentdf#3774](opentdf#3774))
([49c80a0](opentdf@49c80a0))
* **cli:** add an sdkfactory for optional override in otdfctl for
extension ([opentdf#3793](opentdf#3793))
([c2f2afe](opentdf@c2f2afe))
* **cli:** add dynamic value mapping CRUD commands and e2e tests
([opentdf#3768](opentdf#3768))
([aecd265](opentdf@aecd265))
* **cli:** expose handler hook for injecting SDK options
([opentdf#3755](opentdf#3755))
([76305b0](opentdf@76305b0))
* **cli:** Unsafe update key cli
([opentdf#3733](opentdf#3733))
([65d888e](opentdf@65d888e))


### Bug Fixes

* **deps:** bump github.com/opentdf/platform/protocol/go from 0.36.0 to
0.39.0 in /otdfctl
([opentdf#3765](opentdf#3765))
([a3346f8](opentdf@a3346f8))
* **deps:** bump github.com/opentdf/platform/sdk from 0.25.0 to 0.27.0
in /otdfctl ([opentdf#3773](opentdf#3773))
([490c990](opentdf@490c990))
* **policy:** GetPC does not respect manager field.
([opentdf#3752](opentdf#3752))
([0d3c0a0](opentdf@0d3c0a0))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
Co-authored-by: Elizabeth Healy <35498075+elizabethhealy@users.noreply.github.com>
khvirtru pushed a commit to khvirtru/platform that referenced this pull request Aug 5, 2026
🤖 I have created a release *beep* *boop*
---


##
[0.36.0](opentdf/platform@otdfctl/v0.35.0...otdfctl/v0.36.0)
(2026-08-04)


### ⚠ BREAKING CHANGES

* **policy:** GetPC does not respect manager field.
([opentdf#3752](opentdf#3752))

### Features

* **authz:** dynamic value mapping and direct entitlement e2e coverage
([opentdf#3774](opentdf#3774))
([49c80a0](opentdf@49c80a0))
* **cli:** add an sdkfactory for optional override in otdfctl for
extension ([opentdf#3793](opentdf#3793))
([c2f2afe](opentdf@c2f2afe))
* **cli:** add dynamic value mapping CRUD commands and e2e tests
([opentdf#3768](opentdf#3768))
([aecd265](opentdf@aecd265))
* **cli:** expose handler hook for injecting SDK options
([opentdf#3755](opentdf#3755))
([76305b0](opentdf@76305b0))
* **cli:** Unsafe update key cli
([opentdf#3733](opentdf#3733))
([65d888e](opentdf@65d888e))


### Bug Fixes

* **deps:** bump github.com/opentdf/platform/protocol/go from 0.36.0 to
0.39.0 in /otdfctl
([opentdf#3765](opentdf#3765))
([a3346f8](opentdf@a3346f8))
* **deps:** bump github.com/opentdf/platform/sdk from 0.25.0 to 0.27.0
in /otdfctl ([opentdf#3773](opentdf#3773))
([490c990](opentdf@490c990))
* **policy:** GetPC does not respect manager field.
([opentdf#3752](opentdf#3752))
([0d3c0a0](opentdf@0d3c0a0))

---
This PR was generated with [Release
Please](https://github.com/googleapis/release-please). See
[documentation](https://github.com/googleapis/release-please#release-please).

Co-authored-by: opentdf-automation[bot] <149537512+opentdf-automation[bot]@users.noreply.github.com>
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.

2 participants