Add generator metadata (wfctl version + plugin versions) to IaC plans and state#625
Conversation
… and state Agent-Logs-Url: https://github.com/GoCodeAlone/workflow/sessions/c7d303ed-8d67-4f52-82f2-117dc0e18193 Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
⏱ Benchmark Results✅ No significant performance regressions detected. benchstat comparison (baseline → PR)
|
There was a problem hiding this comment.
Pull request overview
Adds “generator metadata” to IaC artifacts produced by wfctl so operators can tell which wfctl binary and IaC provider plugin versions generated a given plan/state output.
Changes:
- Extend IaC plan schema with
generator_metadata(wfctl version + plugin versions). - Add generator-metadata collection + persistence: embedded in
plan.json, and written as ametadata.jsonsidecar for filesystem state after apply. - Extend IaC plugin manifest parsing to capture plugin
nameandversion, and add tests/docs for the new metadata.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
interfaces/iac_state.go |
Adds PluginVersionInfo / GeneratorMetadata types and embeds generator metadata into IaCPlan. |
cmd/wfctl/deploy_providers.go |
Extends iacPluginManifest to parse plugin name and version from plugin.json. |
cmd/wfctl/infra_generator_metadata.go |
Implements generator metadata snapshotting and IaC plugin version collection. |
cmd/wfctl/infra.go |
Stamps metadata into plan.json and attempts best-effort post-apply metadata persistence to state store. |
cmd/wfctl/infra_state_store.go |
Adds metadataPersister optional interface; filesystem store writes metadata.json and excludes it from ListResources. |
cmd/wfctl/infra_generator_metadata_test.go |
Adds unit tests for plugin scanning, metadata persistence, overwrite behavior, and plan JSON round-trip/omitempty. |
docs/WFCTL.md |
Documents the new generator metadata behavior and storage locations. |
|
@copilot apply changes based on the comments in this thread |
… handling Agent-Logs-Url: https://github.com/GoCodeAlone/workflow/sessions/65f4a5ce-6a75-4e04-8f18-59b6765346d3 Co-authored-by: intel352 <77607+intel352@users.noreply.github.com>
Applied all five review points in commit
|
Summary
Tracks the wfctl binary version and the versions of all loaded IaC provider plugins whenever an infrastructure plan or apply operation produces output on disk. This makes it straightforward to know what toolchain version produced a given state artifact and what upgrades may be required when behavior has changed between versions.
Changes
interfaces/iac_state.goPluginVersionInfostruct (name,version)GeneratorMetadatastruct (wfctl_version,plugins []PluginVersionInfo)GeneratorMetadata *GeneratorMetadatafield toIaCPlan(JSON:generator_metadata,omitempty)cmd/wfctl/deploy_providers.goName stringandVersion stringfields toiacPluginManifestso the plugin scanner now captures each IaC plugin's declared version fromplugin.jsoncmd/wfctl/infra_generator_metadata.go(new)buildGeneratorMetadata()— builds aGeneratorMetadatasnapshot with the current wfctl version + installed IaC plugin versionscollectIaCPluginVersions()— scansWFCTL_PLUGIN_DIR(default./data/plugins) for subdirectories whoseplugin.jsondeclares aniacProvidercapability, and returns their name + versioncmd/wfctl/infra.gorunInfraPlan: populatesplan.GeneratorMetadatabefore writingplan.jsonrunInfraApply: after a successful apply, callsmetadataPersister.SaveMetadataon the state store (best-effort, warns on failure)cmd/wfctl/infra_state_store.gometadataPersisteroptional interface (SaveMetadata(ctx, GeneratorMetadata) error)SaveMetadataonfsWfctlStateStore— writes<state-dir>/metadata.json(overwritten on every apply so it reflects the most-recent operation)ListResourcesnow skipsmetadata.json(alongside the existing.lock.jsonexclusion)docs/WFCTL.mdinfra applydocumenting the newgenerator_metadatafield andmetadata.jsonsidecarcmd/wfctl/infra_generator_metadata_test.go(new)SaveMetadatawrite + ListResources exclusion, overwrite semantics, and IaCPlan JSON round-trip /omitemptyWhere the metadata is stored
wfctl infra plan -o plan.jsonplan.jsonasgenerator_metadatawfctl infra apply(filesystem state backend)<state-dir>/metadata.jsonRemote backends (Spaces, Postgres) do not yet write a sidecar file; the plan.json covers the primary use case. The
metadataPersisteroptional interface makes it easy to add support to other backends in follow-up PRs.