[Automated] Update terraform CLI Options#2572
Conversation
Up to standards ✅🟢 Issues
|
| Metric | Results |
|---|---|
| Complexity | ✅ 0 (≤ 20 complexity) |
NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.
There was a problem hiding this comment.
Code Review — Automated Terraform CLI Options Update
Overview
This automated PR syncs the Terraform options classes from the installed CLI binary. It adds two new service methods (TerraformState.Pull(), TerraformProviders.Schema()), two new options classes, adds -var-file across 12+ existing options classes, adds -test-directory to a few classes, and fixes a duplicate-word typo in TerraformTestOptions.
⚠️ Primary Concern: -var-file Added to Commands That Don't Support It
This is the most significant issue in the PR. The generator appears to have treated -var-file as a global option and applied it to every subcommand. In Terraform's actual CLI, -var-file is only valid for commands that evaluate configuration and consume input variables: apply, plan, destroy, refresh, import, console, and test.
The following commands do not accept -var-file, so a user setting VarFile on these options classes will get a runtime CLI error with no compile-time warning — which defeats the entire purpose of a strongly-typed options API:
terraform state mv / rm / push / pull / replace-provider— state manipulation doesn't use variable filesterraform graph— graph output doesn't consume variablesterraform providers / providers lock / providers mirror / providers schematerraform modules,terraform init,terraform get,terraform taint,terraform validate
Why this matters architecturally: The value proposition of these generated options classes is correctness — they should represent the actual CLI surface. Exposing VarFile on TerraformStateRmOptions is actively misleading and will cause silent runtime failures.
Recommended fix: Update tools/ModularPipelines.OptionsGenerator/ to filter out options that don't apply to a given subcommand, e.g., via a (command, option) denylist or by parsing per-subcommand help output independently from global help output. This is a generator-level fix, not a generated-file fix.
⚠️ VarFile Typed as string? But Supports Multiple Values
Every VarFile property carries the doc comment:
"Use this option more than once to include more than one variables file."
Yet the property is typed as string?, which only allows one file. A user needing multiple var files has no type-safe way to express that.
Suggested type: IEnumerable<string>? (or string[]?), assuming the [CliOption] attribute in this framework supports collection rendering. This is a pre-existing issue that this PR expands the surface area of.
⚠️ New TerraformProvidersSchemaOptions Is Missing Its Key Flag
terraform providers schema requires -json — without it the command is not useful (it's the only output mode). The new options class only exposes VarFile (which, per the above, doesn't apply) and omits -json. A complete class would be:
[CliFlag("-json")]
public bool? Json { get; set; }⚠️ New TerraformStatePullOptions Has No Applicable Options
terraform state pull takes no flags — it simply dumps the state to stdout. The generated class only contains VarFile, which is inapplicable. The class should either be empty or contain only inheritable common options that genuinely apply.
✅ Positives
TerraformState.Pull()andTerraformProviders.Schema()are legitimate missing methods — these are real, useful Terraform subcommands and adding them to the service layer is correct.- Docstring typo fix in
TerraformTestOptions("using the the -cloud-run option"→"using the -cloud-run option") is a clean improvement. - The overall generation pattern is consistent with existing classes.
Summary
The two new service methods and the typo fix are good changes. However, the -var-file propagation to non-applicable commands is a systematic generator issue that risks shipping a misleading public API. The root fix belongs in the generator's option-filtering logic. Merging as-is means 13+ options classes will expose a property that silently causes runtime failures when used.
Summary
This PR contains automatically generated updates to terraform CLI options classes.
The generator scraped the latest CLI help output from the installed tool.
Changes
Verification
🤖 Generated with ModularPipelines.OptionsGenerator