Merge pull request #27906 from hashicorp/alisdair/remove-var-args-from-validate

cli: Remove -var/-var-file flags from validate
This commit is contained in:
Alisdair McDiarmid 2021-02-24 12:43:53 -05:00 committed by GitHub
commit 326583bb6e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 0 additions and 18 deletions

View File

@ -19,19 +19,10 @@ type ValidateCommand struct {
func (c *ValidateCommand) Run(args []string) int {
args = c.Meta.process(args)
// TODO: The `var` and `var-file` options are not actually used, and should
// be removed in the next major release.
if c.Meta.variableArgs.items == nil {
c.Meta.variableArgs = newRawFlags("-var")
}
varValues := c.Meta.variableArgs.Alias("-var")
varFiles := c.Meta.variableArgs.Alias("-var-file")
var jsonOutput bool
cmdFlags := c.Meta.defaultFlagSet("validate")
cmdFlags.BoolVar(&jsonOutput, "json", false, "produce JSON output")
cmdFlags.Var(varValues, "var", "variables")
cmdFlags.Var(varFiles, "var-file", "variable file")
cmdFlags.Usage = func() { c.Ui.Error(c.Help()) }
if err := cmdFlags.Parse(args); err != nil {
c.Ui.Error(fmt.Sprintf("Error parsing command-line flags: %s\n", err.Error()))
@ -40,15 +31,6 @@ func (c *ValidateCommand) Run(args []string) int {
var diags tfdiags.Diagnostics
// If set, output a warning indicating that these values are not used.
if !varValues.Empty() || !varFiles.Empty() {
diags = diags.Append(tfdiags.Sourceless(
tfdiags.Warning,
"The -var and -var-file flags are not used in validate. Setting them has no effect.",
"These flags will be removed in a future version of Terraform.",
))
}
// After this point, we must only produce JSON output if JSON mode is
// enabled, so all errors should be accumulated into diags and we'll
// print out a suitable result at the end, depending on the format