command: Restore support for terraform.tfvars.json

In the new implementation of collecting variables I initially forgot the
JSON variant of terraform.tfvars.

This fix is verified by TestApply_varFileDefaultJSON now passing.
This commit is contained in:
Martin Atkins 2018-10-16 07:38:09 -07:00
parent 46b4c27dbe
commit 7abf81d8da
1 changed files with 5 additions and 0 deletions

View File

@ -62,6 +62,11 @@ func (m *Meta) collectVariableValues() (map[string]backend.UnparsedVariableValue
moreDiags := m.addVarsFromFile(DefaultVarsFilename, terraform.ValueFromFile, ret)
diags = diags.Append(moreDiags)
}
const defaultVarsFilenameJSON = DefaultVarsFilename + ".json"
if _, err := os.Stat(defaultVarsFilenameJSON); err == nil {
moreDiags := m.addVarsFromFile(defaultVarsFilenameJSON, terraform.ValueFromFile, ret)
diags = diags.Append(moreDiags)
}
if infos, err := ioutil.ReadDir("."); err == nil {
// "infos" is already sorted by name, so we just need to filter it here.
for _, info := range infos {