refactor(region): simplify and fix region selection plugin#897
Merged
Conversation
- Replace inline region normalization with normalizeRegionName() everywhere - Remove skuInfo single-field struct; use string directly - Fix January date bug: use now.AddDate(0,-1,0) instead of now.Month()-1 - Remove targetRegionsFlag package-level global; bridge --target-regions CLI flag through stageConfigs in scanWithPlugin so target regions flow through ScanParams.Stages (same as MCP path) with no global state - Remove stale 'can be made configurable' comment from calculateScores Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #897 +/- ##
==========================================
+ Coverage 20.84% 21.32% +0.47%
==========================================
Files 107 107
Lines 7526 7518 -8
==========================================
+ Hits 1569 1603 +34
+ Misses 5843 5801 -42
Partials 114 114
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #896
What
Analysis and cleanup of the region selection plugin based on a code review.
Changes
Bug fixes
cost.go): replacenow.Month()-1withnow.AddDate(0,-1,0)— idiomatic, unambiguous previous-month calculationplugin.go,scan.go): removedtargetRegionsFlagpackage-level global. The--target-regionsCLI flag value is now bridged throughstageConfigsinscanWithPlugin, making the CLI and MCP paths consistent (both useScanParams.Stages). A second scan call with notarget-regionsno longer silently inherits regions from the previous call.Simplifications
strings.ToLower(strings.ReplaceAll(region, " ", ""))expressions withnormalizeRegionName()(selection.go,availability.go,latency.go)skuInfosingle-field struct; usestringdirectly (types.go,selection.go)calculateScores(selection.go)Testing
go test ./internal/scanners/plugins/region/...✅go test ./internal/mcpserver/...✅go build ./cmd/azqr/...✅