Merge pull request #9698 from hashicorp/b-simple-var
terraform: disallow simple variables ("foo")
This commit is contained in:
commit
261f0ee592
|
@ -285,12 +285,14 @@ func (i *Interpolater) valueSimpleVar(
|
||||||
n string,
|
n string,
|
||||||
v *config.SimpleVariable,
|
v *config.SimpleVariable,
|
||||||
result map[string]ast.Variable) error {
|
result map[string]ast.Variable) error {
|
||||||
// SimpleVars are never handled by Terraform's interpolator
|
// This error message includes some information for people who
|
||||||
result[n] = ast.Variable{
|
// relied on this for their template_file data sources. We should
|
||||||
Value: config.UnknownVariableValue,
|
// remove this at some point but there isn't any rush.
|
||||||
Type: ast.TypeString,
|
return fmt.Errorf(
|
||||||
}
|
"invalid variable syntax: %q. If this is part of inline `template` parameter\n" +
|
||||||
return nil
|
"then you must escape the interpolation with two dollar signs. For\n" +
|
||||||
|
"example: ${a} becomes $${a}." +
|
||||||
|
n)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (i *Interpolater) valueUserVar(
|
func (i *Interpolater) valueUserVar(
|
||||||
|
|
|
@ -13,6 +13,12 @@ import (
|
||||||
"github.com/hashicorp/terraform/config"
|
"github.com/hashicorp/terraform/config"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func TestInterpolater_simpleVar(t *testing.T) {
|
||||||
|
i := &Interpolater{}
|
||||||
|
scope := &InterpolationScope{}
|
||||||
|
testInterpolateErr(t, i, scope, "simple")
|
||||||
|
}
|
||||||
|
|
||||||
func TestInterpolater_countIndex(t *testing.T) {
|
func TestInterpolater_countIndex(t *testing.T) {
|
||||||
i := &Interpolater{}
|
i := &Interpolater{}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue