feat: add -plugin-dir flag to wfctl infra commands#647
Conversation
⏱ Benchmark Results✅ No significant performance regressions detected. benchstat comparison (baseline → PR)
|
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
…ication Agent-Logs-Url: https://github.com/GoCodeAlone/workflow/sessions/6e7afe9a-df1d-4fe0-abcf-44a067bd34c8 Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Adds a --plugin-dir override to wfctl infra subcommands so CI (and local smoke tests) can load IaC provider plugins from an isolated directory, with precedence --plugin-dir → WFCTL_PLUGIN_DIR → ./data/plugins.
Changes:
- Introduces a per-invocation
currentInfraPluginDirseam and updates IaC provider discovery to consult it first. - Registers
--plugin-diracross the main infra plugin-loading subcommands and threads the value viacurrentInfraPluginDir. - Adds a new test suite to verify flag acceptance, seam propagation, and post-command reset; updates
docs/WFCTL.mdaccordingly.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/WFCTL.md | Documents --plugin-dir for infra commands and adds CI usage examples. |
| cmd/wfctl/infra.go | Adds --plugin-dir flag and publishes it via currentInfraPluginDir for plan/apply/status/drift/destroy/import. |
| cmd/wfctl/infra_rotate_and_prune.go | Adds --plugin-dir flag + seam publish/reset for rotate-and-prune. |
| cmd/wfctl/infra_prune.go | Adds --plugin-dir flag + seam publish/reset for prune. |
| cmd/wfctl/infra_plugin_dir_test.go | New tests ensuring --plugin-dir is accepted and correctly influences provider loading. |
| cmd/wfctl/infra_cleanup.go | Adds --plugin-dir flag + seam publish/reset for cleanup. |
| cmd/wfctl/infra_audit_keys.go | Adds --plugin-dir flag + seam publish/reset for audit-keys. |
| cmd/wfctl/infra_align.go | Adds --plugin-dir flag + seam publish/reset for align. |
| cmd/wfctl/deploy_providers.go | Adds currentInfraPluginDir seam and makes provider discovery prefer it over env/default. |
| | `--parallelism` | `10` | Number of parallel operations | | ||
| | `--lock-timeout` | `0s` | Timeout for state lock acquisition | | ||
| | `--force-rotate` | `` | (`bootstrap` only) Comma-separated list of secret names to regenerate, replacing existing values. Repeatable. Use to recover from known-bad secrets (empty value, leaked, dead key). Refuses `provider_credential` types. | | ||
| | `--plugin-dir` | _(env `WFCTL_PLUGIN_DIR` or `data/plugins`)_ | Override the plugin directory for plugin-loading commands (plan, apply, status, drift, destroy, import, cleanup, align, audit-keys, prune, rotate-and-prune). Useful for isolated CI smoke tests. | |
| var pluginDirFlag string | ||
| fs.StringVar(&pluginDirFlag, "plugin-dir", "", "Plugin directory (overrides WFCTL_PLUGIN_DIR and default data/plugins)") | ||
| if err := fs.Parse(args); err != nil { | ||
| return err | ||
| } | ||
| currentInfraPluginDir = pluginDirFlag | ||
| defer func() { currentInfraPluginDir = "" }() |
|
@copilot apply changes based on the comments in this thread Test coverage is also lacking: #647 (comment) |
…ore seam Agent-Logs-Url: https://github.com/GoCodeAlone/workflow/sessions/79a0a010-7801-4b98-859b-42d230af55a2 Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Added Also fixed a subtle interaction: Tests were added for both |
wfctl plugin installaccepted-plugin-dirbutwfctl infra apply(and all other infra commands that load external plugins) did not, making isolated CI verification with a custom plugin directory impossible.Approach
Added a
currentInfraPluginDirpackage-level seam variable indeploy_providers.go(same pattern ascurrentApplyIncludeFlag).discoverAndLoadIaCProvidernow checks it beforeWFCTL_PLUGIN_DIRand the./data/pluginsdefault.All commands use a save/restore pattern (
prevInfraPluginDir := currentInfraPluginDir; defer func() { currentInfraPluginDir = prevInfraPluginDir }()) rather than a hard reset to"". This correctly handlesrunInfraApplycallingrunInfraBootstrapas a sub-call — bootstrap's deferred restore returns the parent's plugin dir rather than clobbering it with"".Changes
deploy_providers.go— addcurrentInfraPluginDirseam var; check it first indiscoverAndLoadIaCProviderinfra.go— add-plugin-dirtoplan,apply,status,drift,destroy,import; thread--plugin-dirthrough bootstrap sub-call argsinfra_bootstrap.go— add-plugin-dirtobootstrapinfra_refresh_outputs.go— add-plugin-dirtorefresh-outputsinfra_cleanup.go— add-plugin-dirtocleanupinfra_align.go— add-plugin-dirtoaligninfra_audit_keys.go— add-plugin-dirtoaudit-keysinfra_prune.go— add-plugin-dirtopruneinfra_rotate_and_prune.go— add-plugin-dirtorotate-and-pruneinfra_plugin_dir_test.go(new) — verifies flag acceptance, correct seam threading, post-command reset, and precedence overWFCTL_PLUGIN_DIRfor all major commands includingbootstrapandrefresh-outputsdocs/WFCTL.md— documents--plugin-dirin all affected command tablesUsage
Priority order for plugin directory resolution:
-plugin-dirflag →WFCTL_PLUGIN_DIRenv var →./data/pluginsdefault.