Skip to content

feat: opa validations policy rule#56

Merged
adityachoudhari26 merged 2 commits intomainfrom
opa-validation-tf
May 4, 2026
Merged

feat: opa validations policy rule#56
adityachoudhari26 merged 2 commits intomainfrom
opa-validation-tf

Conversation

@adityachoudhari26
Copy link
Copy Markdown
Member

@adityachoudhari26 adityachoudhari26 commented May 4, 2026

Summary by CodeRabbit

  • New Features
    • Added ability to manage dependencies for deployment versions
    • Added support for OPA plan validation rules in policies

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 4, 2026

Warning

Rate limit exceeded

@adityachoudhari26 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 27 minutes and 27 seconds before requesting another review.

To keep reviews running without waiting, you can enable usage-based add-on for your organization. This allows additional reviews beyond the hourly cap. Account admins can enable it under billing.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 3e6f0ea5-9784-4844-b6cc-72c0427e02c7

📥 Commits

Reviewing files that changed from the base of the PR and between 487551f and f1c2fe8.

📒 Files selected for processing (3)
  • docs/resources/policy.md
  • internal/api/client.gen.go
  • internal/provider/policy_resource.go
📝 Walkthrough

Walkthrough

This PR extends the API client with support for deployment version dependency management (list, delete, upsert operations) and OPA plan validation policy rules. It adds corresponding data types, request/response plumbing in the generated client, integrates OPA rule support into the Terraform provider's policy resource schema and model, and changes the deployment version creation response from HTTP 202 to HTTP 200.

Changes

Dependency Management & Policy Rules API Support

Layer / File(s) Summary
Data Shape
internal/api/client.gen.go
New types added: DeploymentVersionDependency (with DependencyDeploymentId, DeploymentVersionId, VersionSelector), PlanValidationOpaRule (with Description, Name, Rego). Existing types extended: CreateDeploymentVersionRequest gains Dependencies field; CreatePolicyRule and UpsertPolicyRule gain PlanValidationOpa field; CreateDeploymentVersionResponse field changed from JSON202 to JSON200.
API Client Plumbing
internal/api/client.gen.go
Request constructors added: NewListDeploymentVersionDependenciesRequest, NewRequestDeploymentVersionDeletionRequest, NewRequestDeploymentVersionUpsertRequest (with WithBody variants). ClientInterface extended with four new dependency-management methods. Client concrete implementation adds corresponding methods. Response types added: ListDeploymentVersionDependenciesResponse, RequestDeploymentVersionDependencyDeletionResponse, RequestDeploymentVersionDependencyUpsertResponse. ClientWithResponsesInterface and ClientWithResponses wrappers add typed response methods and parsing.
Terraform Provider Schema & Model
internal/provider/policy_resource.go
PolicyResourceModel adds PlanValidationOpa []PolicyPlanValidationOpa field. New type PolicyPlanValidationOpa created with CreatedAt, ID, Name, Description, Rego. Provider schema adds plan_validation_opa nested block. policyRulesModel and policyRequestRule include the new rule type.
Provider Conversion Logic
internal/provider/policy_resource.go
policyRulesFromModel adds conversion loop for PlanValidationOpa items with validation of name and rego. policyRulesToModel adds reverse conversion from API PlanValidationOpaRule to provider model. ensurePolicyIDs and ensurePolicyRuleCreatedAt extended to stabilize ID and created_at for OPA rules via helper functions mergePlanValidationOpaIDs and mergePlanValidationOpaCreatedAt. Provider Read and Update methods assign/read PlanValidationOpa from converted API rules.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

  • #16: Modifies internal/provider/policy_resource.go to add a different policy rule type and updates the same helper functions (ensurePolicyIDs, ensurePolicyRuleCreatedAt, policyRulesFromModel, policyRulesToModel) to support additional rules.
  • #17: Touches policy handling and client response parsing—modifying policy resource read/update logic and generated client response types (JSON200/JSON202 handling).

Poem

🐰 New rules for OPA dance and play,
Dependencies linked in every way,
The client speaks in HTTP 200,
Provider schemas learn what's true,
From API's plan to state so bright! ✨

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 54.55% 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 PR title 'feat: opa validations policy rule' directly and clearly describes the main change: adding OPA validation support to policy rules across the API client and Terraform provider.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch opa-validation-tf

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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
Review rate limit: 0/1 reviews remaining, refill in 27 minutes and 27 seconds.

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

@adityachoudhari26 adityachoudhari26 merged commit a8ce2e9 into main May 4, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant