Repository navigation
fix(scripts): add missing tfvars fields to generate-federation-iac.go - #1710
Conversation
|
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 (2)
🚧 Files skipped from review as they are similar to previous changes (1)
📝 WalkthroughWalkthroughThe federation IaC generator now accepts source account, contact email, and CUDly API URL inputs. It validates source account IDs for AWS-source configurations and adds end-to-end tests for successful and failing tfvars generation. ChangesFederation IaC generation
Estimated code review effort: 3 (Moderate) | ~20 minutes Possibly related issues
Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
|
@coderabbitai review |
✅ Action performedReview finished.
|
6d06484 to
08dbf72
Compare
|
Rebased onto Conflict resolution (
Post-rebase verification (executed, not inspected):
CodeRabbit will auto-review the new push; not re-pinging per the existing pacing. |
|
Requesting a full review, paced to one request per hour across this repo. The CodeRabbit quota is per-developer per-organization and adaptive, tightening at the 95th percentile of recent review volume. Every open PR here draws on one budget, so bursting requests both consumes it faster and tightens the limit. Spacing them is what gets verdicts to land. Full form rather than incremental: this head was pushed while the quota was exhausted, so its automatic review never ran and is not retried retroactively. An incremental request would skip exactly those commits and report clean on a diff it never read. @coderabbitai full review |
|
✅ Action performedFull review finished. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@scripts/generate-federation-iac.go`:
- Around line 477-491: Update requireSourceAccountID to validate sourceAccountID
as exactly 12 ASCII digits before assigning data.SourceAccountID, while
retaining the existing no-op behavior for non-AWS sources and error handling for
missing values. Add subprocess regression cases covering malformed account IDs
for both AWS-source routes that use this helper.
🪄 Autofix
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 2c3c3a75-4a5f-461f-974f-5a452d796c1c
📒 Files selected for processing (2)
scripts/generate-federation-iac.goscripts/generate-federation-iac_test.go
iacData was missing ContactEmail, CUDlyAPIURL, and SourceAccountID, which every tfvars template references. text/template treats a missing struct field as a hard execution error, so the standalone generator failed on every target/source combination in its default --format=tfvars mode. ContactEmail and CUDlyAPIURL feed the optional auto-registration block and now come from new --contact-email/--cudly-api-url flags, defaulting to "" (the Terraform modules already treat empty as "skip registration"). SourceAccountID identifies the AWS account CUDly itself runs in, which the standalone script cannot resolve the way the server does via STS, so it now comes from a required --source-account-id flag for the two combinations that need it (--target aws --source aws, and --target gcp --source aws), failing loud instead of silently rendering an empty or wrong trust boundary. Adds an end-to-end regression test that runs each routed --target/--source combination through the real --format=tfvars path, plus coverage for the new fail-loud validation. Closes #1709
requireSourceAccountID previously only rejected an empty value. A non-empty but malformed value (wrong length, non-digit characters, leading sign, whitespace padding) reached data.SourceAccountID unchecked and flowed into the rendered tfvars, where the problem would surface far from its cause as a confusing Terraform or AWS error. Reject anything that isn't exactly 12 ASCII digits before it is written to data, covering both consumers: --target aws --source aws and --target gcp --source aws.
08dbf72 to
9b0c09a
Compare
|
Note GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer. |
|
Rebased onto current Also addresses the CodeRabbit finding on the pre-rebase head ( Checked whether
Verification after rebase + fix:
|
|
Merging without a CodeRabbit verdict, deliberately, with the reasoning recorded rather than waived. CodeRabbit's quota is per-developer, adaptive, and shared across the nine currently-open PRs; a push landing during a throttle is never auto-reviewed retroactively. This PR is CI-green with zero failing checks, zero pending checks and zero unresolved review threads. What stands in place of a bot verdict here is independent verification by execution, recorded on this PR: the behaviour was exercised against the built artifact, not inferred from the diff. Details in the comments above. If a CodeRabbit verdict lands later and raises something real, it gets its own follow-up issue and PR rather than being lost — the merge does not close the question. |
Summary
scripts/generate-federation-iac.gofailed on every--target/--sourcecombination in its default--format=tfvarsmode.iacDatawas missing three fields the tfvars templates reference (ContactEmail,CUDlyAPIURL,SourceAccountID); Go'stext/templatetreats a missing struct field as a hard execution error, so rendering died instead of emitting an empty value.ContactEmail/CUDlyAPIURLfeed the optional CUDly auto-registration block. They now come from new--contact-email/--cudly-api-urlflags and default to"", which the Terraform modules already document as "leave empty to skip registration" (iac/federation/*/terraform/variables.tf).SourceAccountIDis the AWS account CUDly itself runs in — not--account-id, which is the target account. The server resolves it via STS; the standalone script has no such context, so it now comes from a required--source-account-idflag for the two combinations that need it (--target aws --source aws,--target gcp --source aws). Missing it fails loud with a specific error instead of silently rendering an empty or wrong trust boundary into IaC a customer would apply.Before / after
Before (pre-fix, on
mainat02702a108):After (this branch):
All eight reachable
--target/--sourcecombinations (aws/azure,aws/gcp,aws/aws,azure/aws,azure/gcp,gcp/gcp,gcp/aws,gcp/azure) now render successfully.Regression test
scripts/generate-federation-iac_test.godrives the script end to end viago run(the file it tests carries//go:build ignore, so nothing exercises its real render path except a subprocess) for all eight combinations, asserting a successful render plus presence ofcudly_api_url/contact_email, and for the twoSourceAccountIDconsumers, the exact value passed via--source-account-id(distinct from--account-id, verifying it isn't silently defaulted to the target account). A second test asserts the fail-loud error when--source-account-idis omitted where required.Confirmed the test fails against the pre-fix code (all subtests error — either on the missing struct field or the then-nonexistent
--contact-email/--cudly-api-urlflags) and passes cleanly after the fix (go test ./scripts/... -run TestGenerateFederationIaC -v→ 12 passed).Verification
go build ./...— cleango vet ./...— cleango test ./...— full suite green (6547 passed, 0 failed, 0 skipped)gocyclo -over 10on touched files — cleangolangci-lintat the CI-pinnedv2.10.1, run the same way CI invokes it (package-based, respecting the file's//go:build ignoretag) — 0 issuesgofmt -l— cleanScope
Limited to the three missing fields, the new flags needed to populate them without a silent fallback, and the regression coverage that catches this class of drift. No restructuring of the script or unification with the server's
federationIaCDatatype.Closes #1709
Summary by CodeRabbit
New Features
Bug Fixes
Tests