feat(wfctl): infra import-all bulk wrapper#786
Merged
Conversation
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Two follow-up fixes after PR 786's first CI pass: 1. cmd/wfctl/infra_import_all.go:169 — staticcheck S1039 flagged fmt.Sprintf with no format directives. Replaced with the plain string literal. 2. cmd/wfctl/infra_import_all_e2e_test.go — the dry-run → real-run transition mutated args in-place (args[len(args)-1] = "--type"; append; dropFlag) which assumed --dry-run was always the last element. When WFCTL_E2E_DO_PLUGIN_DIR was set the plugin-dir path took the last slot and the rewrite corrupted the flag list. Rebuild each pass cleanly off a baseArgs slice so the transition is order-independent. dropFlag helper deleted (no longer needed).
⏱ Benchmark Results✅ No significant performance regressions detected. benchstat comparison (baseline → PR)
|
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.
Summary
Adds
wfctl infra import-all— a bulk wrapper that resolves a singleiac.providermodule from the config, calls the provider'sIaCProviderEnumerator.EnumerateAll(resourceType), then iteratesIaCProvider.Importfor each enumerated cloud ID, persisting each synthesizedResourceStateinto the configurediac.statebackend.Per-zone failure isolation: a single Import failure does NOT abort the loop; failures accumulate and surface as one error at the end. Non-zero exit when any zone failed — matches the design's Phase 2 contract.
Flags
--provider--typeinfra.dns--config/-c--env--dry-run--plugin-dir--output/-oArchitecture
cmd/wfctl/infra_import_all.go(new) — public CLI entry + testable dispatch core + 3 helpers (resolveProviderModuleByName,buildResourceStateFromImport,dumpStateToFile,sanitizeImportedZoneName).cmd/wfctl/infra.go—case "import-all"inrunInfraswitch + usage-line addition.resolveIaCProvider,resolveStateStore,isNoopStateStore,resourceStateFromImportedState,infraStateStore(package-private),currentInfraPluginDir,resolveInfraConfig,infraPreserveKeys.resolveProviderModuleByNamemirrorsresolveProviderForSpec(line-for-line) but indexes by module NAME — the bulk wrapper has no per-resource spec.Verification
Unit tests:
TestRunInfraImportAll_requiresProvider— missing--providerflag error.TestRunInfraImportAll_requiresType— missing--typeflag error.TestRunInfraImportAllWithDeps_dispatch— happy path: 2 zones enumerated → 2 Import calls → 2 ResourceStates saved.TestRunInfraImportAllWithDeps_dryRun— Import probed for each zone, ZERO state saved.TestRunInfraImportAllWithDeps_perZoneFailureIsolation— failing zone does NOT abort siblings; error summarizes failures.TestRunInfraImportAllWithDeps_requiresEnumerator— clean error for providers without EnumeratorAll (no panic).TestRunInfraImportAllWithDeps_enumerateError— early-abort path when EnumerateAll itself errors.TestDumpStateToFile— JSON output, 0o600 file mode.TestSanitizeImportedZoneName— table-driven slug mapping.End-to-end (env-gated, build-tagged
e2e_dns_import):TestInfraImportAll_e2e_DO— drivesrunInfraImportAllagainst a realworkflow-plugin-digitaloceanplugin loaded from disk; requiresWFCTL_E2E_DNS_IMPORT=1+DIGITALOCEAN_TOKEN.All green (132s).
Part of cross-repo cascade
docs/plans/2026-05-26-dns-provider-contract.md(workflow-plugin-infra). PR 6 of 9. Depends on PRs 1-4 (provider plugin EnumerateAll) — all merged + tagged + workflow-registry pin-bumped via PR 5.Test plan
GOWORK=off go test ./cmd/wfctl/...— greenGOWORK=off go vet -tags e2e_dns_import ./cmd/wfctl/...— clean🤖 Generated with Claude Code