feat(commitmentopts/azure): probe Savings Plans offerings for live validation - #724
Conversation
…lidation Adds AzureSPProber to internal/commitmentopts, mirroring the AWS RI probe pattern for Azure Savings Plans (term/payment validation). Azure has no catalog-listing endpoint equivalent to AWS Describe*Offerings, so the prober calls RPClient.ValidatePurchase for each candidate (term, billingPlan) pair and retains those the API accepts as live Combos. Candidate set: P1Y/P3Y/P5Y x upfront/monthly; P5Y is dropped at runtime if ValidatePurchase rejects it so persisted combos always reflect live API reality. AzureSPValidateAPI is a one-method interface matching *armbillingbenefits.RPClient so tests substitute a struct mock without touching the Azure RP. DefaultAzureProbers() returns the default slice for service wiring. Closes #659
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR adds an Azure Savings Plans probe implementation to discover which term and billing plan combinations are accepted by Azure's Billing Benefits ValidatePurchase endpoint, alongside dependency setup and comprehensive test coverage. ChangesAzure Savings Plans Probe
Sequence DiagramsequenceDiagram
participant Caller
participant AzureSPProber
participant client as AzureSPValidateAPI
participant response as ValidatePurchase Response
Caller->>AzureSPProber: ProbeAzure(ctx, cred)
loop for each candidate combo (term, billingPlan)
AzureSPProber->>AzureSPProber: probeCombo(term, billingPlan)
AzureSPProber->>client: ValidatePurchase(SavingsPlanPurchaseValidateRequest)
client-->>response: RPClientValidatePurchaseResponse
AzureSPProber->>AzureSPProber: check per-benefit Valid flags
AzureSPProber->>AzureSPProber: if any invalid, skip combo
end
AzureSPProber-->>Caller: []Combo with accepted combinations or error
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Suggested labels
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Closes #659.
Design
Azure has no catalog-listing endpoint (no
Describe*Offeringsequivalent), so the probe callsarmbillingbenefits.RPClient.ValidatePurchasefor each candidate(term, billingPlan)pair instead:Valid=falseresponse → "not offered, skip" (no error)Files
internal/commitmentopts/probe_azure.go—AzureSPProberstruct +AzureSPValidateAPIinterfaceinternal/commitmentopts/probe_azure_test.go— 12 unit testsInterface duplication note
AzureSPValidateAPIduplicates the one-method interface fromproviders/azure/services/savingsplans.RPValidateAPI— importing the provider package frominternal/would cause a circular dependency. A comment in the file documents this intentional duplication.Deps
armbillingbenefitsmoved from// indirectto direct ingo.mod(go mod tidypre-commit hook handled).Tests
internal/commitmentopts/...: 71 pass (59 pre-existing + 12 new)go vet/ gofmt / golangci-lint cleanSummary by CodeRabbit
New Features
Tests