feat(reconcile): add the BillingPlan reconcile kind - #1854
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
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. Comment |
a91b868 to
bb37c7d
Compare
bb37c7d to
88fbce1
Compare
Coverage Report for CI Build 31151488436Coverage increased (+0.05%) to 47.99%Details
Uncovered Changes
Coverage Regressions1 previously-covered line in 1 file lost coverage.
Coverage Stats
💛 - Coveralls |
88fbce1 to
727734d
Compare
727734d to
2299fa4
Compare
2299fa4 to
d75d588
Compare
d75d588 to
d83141f
Compare
d83141f to
458969a
Compare
What
Adds the BillingPlan reconcile kind, so billing plans can be managed declaratively from a desired-state file (the fifth "kind" after Permission, Role, Preference, Webhook, PlatformUser, and BillingProduct).
internal/reconcile/billingplan.go—BillingPlanSpec, the diff, and validation.internal/reconcile/billingplan_reconciler.go— the reconciler on the AdminService plan APIs (ListAllPlans,CreatePlan,UpdatePlan).cmd/reconcile.go— one registry line; the combinedreconcileAPIalready satisfies the AdminService subset.It mirrors the merged BillingProduct kind:
Kind/Validate/Reconcile/Export, withfetchCurrent→ diff → per-opprotovalidate→apply, plus out-of-scope handling.Design
ListAllPlans(empty state = every plan, active and inactive), soExportround-trips inactive plans and the diff sees them.UpdatePlan: title, description, on_start_credits, trial_days, state.name,interval, and the product set.UpdatePlancannot change them and there is no delete API, so a change to any of them fails the plan (like BillingProduct's immutable prices). A plan is retired by setting its state toinactive, not deleted.CreatePlan's upsert associates them.UpdatePlanis a full write of the fields it carries, so the reconciler reads the current metadata and re-sends it on an update to preserve it (real plans carryplan_group_id, etc.).Deferred (follow-up)
CreatePlan/upsert links products by name; a typo surfaces as a stray product on the next BillingProduct reconcile.reconcile.mdx) section and reconciler-level tests with a mocked API to follow.Stacking
Stacked on #1830 (the plan admin APIs it uses). Rebase onto
mainonce #1830 lands.Testing
Unit tests for the spec validation and the diff (adds, no-op, field updates, state change, immutable interval/products, metadata preservation on update, missing-from-file, duplicates). build, vet, and golangci are green.