Skip to content

refactor(azure): move savings-plan ownership checks into scope.go - #467

Merged
cristim merged 1 commit into
mainfrom
refactor/272-sp-scope-file
Oct 16, 2026
Merged

cristim merged 1 commit into
mainfrom
refactor/272-sp-scope-file

Conversation

@cristim

@cristim cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member

Summary

This is PR A of two for the #272 slice, and it changes no behaviour. PR B is stacked on it and adds the attribution change.

  • planOwnedBy moves unchanged from providers/azure/services/savingsplans/client.go into a new scope.go. client.go was already 633 lines, and B grows this logic.
  • The SDK test client setup in client_completeness_sdk_test.go moves into newFixtureSavingsPlanClient, so B can reuse it. The body is identical. endpoint becomes server.URL, which was already the same value.

Refs #272

Verification (macOS, Go 1.26.9)

  • git diff shows the moved function is byte-identical. Existing tests are unchanged.
  • (cd providers/azure && GOWORK=off go test -race -short ./...) passes.
  • golangci-lint v2.10.1 (CI pin) reports 0 issues. gofmt and gocyclo are clean.
  • An independent non-author reviewer confirmed it is behaviour-neutral.

🤖 Generated with Claude Code

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

  • Run on-demand review

This review includes 3 billable files and costs up to $0.75.

  • Ask an admin to make reviews automatic

Open in CodeRabbit

Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing.

Or wait 34 minutes for your next included review.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available. Your 68 included PR review attempts over the past 7 days set your current allowance at 1 review per hour.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Repository: LeanerCloud/cloud-commitments-go/.coderabbit.yaml
  • Review profile: CHILL
  • Plan: Essentials
  • Run ID: 8cf412c0-f491-4840-bdea-c612ba86f182
📥 Commits

Reviewing files that changed from the base of the PR and between 4453ddd and bf03f8c.

📒 Files selected for processing: 3
  • providers/azure/services/savingsplans/client.go
  • providers/azure/services/savingsplans/client_completeness_sdk_test.go
  • providers/azure/services/savingsplans/scope.go
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

@cristim cristim added priority/p2 Backlog-worthy severity/medium Moderate harm urgency/this-quarter Within the quarter impact/few Limited audience effort/m Days type/feat New capability triaged Item has been triaged labels Oct 16, 2026
@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor
⚠️ Action not completed

Review rate limited.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Independent review verdict: CLEAN at e1d3708

Reviewer: fresh Claude agent (Sonnet, high effort), not the author, cold brief. The PR body was treated as a claim. Coordinator: claude-cc-reviewer.

Blocking findings: none. This is a pure move with no behaviour change, so dedupe is unaffected.

planOwnedBy moved from client.go to scope.go with an identical body:

Branch scope.go
nil sp / Properties / BillingScopeID → error :11
prefix check via hasPrefixFold (case-insensitive) :15
subscription charset validation :19-22
ownership via strings.EqualFold :24
owned but the ID is nil or blank → error :27
  • hasPrefixFold and subscriptionScopePrefix stay in the same package.
  • The only caller is client.go:177, and its signature is unchanged.
  • Test diff: the SDK client setup was extracted into newFixtureSavingsPlanClient with an identical body. No assertions were removed or weakened.

What was attacked and how (providers/azure, GOWORK=off, no Azure calls):

  • go vet ./... is clean. go test -race -count=1 ./... passes, and savingsplans alone passes 108.
  • Mutation probes, both killed:
    • EqualFold changed to != fails TestGetExistingCommitments_SubscriptionOwnership/own-shared-mixed-case.
    • Dropping the not-owned return fails TestGetExistingCommitments_SubscriptionOwnership.

Gate:

Moves planOwnedBy out of client.go (already over 600 lines) into scope.go
unchanged, and extracts the offline SDK fixture client from the pagination
completeness test into newFixtureSavingsPlanClient so later tests can reuse
it. No behavior change; existing tests are untouched.

Refs #272

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@cristim
cristim force-pushed the refactor/272-sp-scope-file branch from e1d3708 to bf03f8c Compare October 16, 2026 21:10
@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

Pure rebase onto main. git range-diff of e1d3708 against new head bf03f8c shows the commit identical (=), so the CLEAN verdict carries. (claude-cc-reviewer)

@cristim

cristim commented Oct 16, 2026

Copy link
Copy Markdown
Member Author

CI is green on head e1d3708: pre-commit 38967123410 and Build & Test 38967123319.

@cristim
cristim merged commit 926d1d5 into main Oct 16, 2026
15 checks passed
@cristim
cristim deleted the refactor/272-sp-scope-file branch October 16, 2026 21:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

effort/m Days impact/few Limited audience priority/p2 Backlog-worthy severity/medium Moderate harm triaged Item has been triaged type/feat New capability urgency/this-quarter Within the quarter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant