Interpolation also skipped during Validate phase
Adding walkValidate to the EvalTree operations, and removing the walkValidate guard from the Interpolater.valueModuleVar allows the values to be interpolated for Validate.
This commit is contained in:
parent
fc4ac52014
commit
ed042ab067
|
@ -749,3 +749,30 @@ func TestContext2Validate_varRefFilled(t *testing.T) {
|
|||
t.Fatalf("bad: %#v", value)
|
||||
}
|
||||
}
|
||||
|
||||
// Module variables weren't being interpolated during Validate phase.
|
||||
// related to https://github.com/hashicorp/terraform/issues/5322
|
||||
func TestContext2Validate_interpolateVar(t *testing.T) {
|
||||
input := new(MockUIInput)
|
||||
|
||||
m := testModule(t, "input-interpolate-var")
|
||||
p := testProvider("null")
|
||||
p.ApplyFn = testApplyFn
|
||||
p.DiffFn = testDiffFn
|
||||
|
||||
ctx := testContext2(t, &ContextOpts{
|
||||
Module: m,
|
||||
Providers: map[string]ResourceProviderFactory{
|
||||
"template": testProviderFuncFixed(p),
|
||||
},
|
||||
UIInput: input,
|
||||
})
|
||||
|
||||
w, e := ctx.Validate()
|
||||
if w != nil {
|
||||
t.Log("warnings:", w)
|
||||
}
|
||||
if e != nil {
|
||||
t.Fatal("err:", e)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,7 +44,8 @@ func (n *GraphNodeConfigOutput) DependentOn() []string {
|
|||
// GraphNodeEvalable impl.
|
||||
func (n *GraphNodeConfigOutput) EvalTree() EvalNode {
|
||||
return &EvalOpFilter{
|
||||
Ops: []walkOperation{walkRefresh, walkPlan, walkApply, walkDestroy, walkInput},
|
||||
Ops: []walkOperation{walkRefresh, walkPlan, walkApply,
|
||||
walkDestroy, walkInput, walkValidate},
|
||||
Node: &EvalSequence{
|
||||
Nodes: []EvalNode{
|
||||
&EvalWriteOutput{
|
||||
|
|
|
@ -130,16 +130,6 @@ func (i *Interpolater) valueModuleVar(
|
|||
v *config.ModuleVariable,
|
||||
result map[string]ast.Variable) error {
|
||||
|
||||
// If we're computing all dynamic fields, then module vars count
|
||||
// and we mark it as computed.
|
||||
if i.Operation == walkValidate {
|
||||
result[n] = ast.Variable{
|
||||
Value: config.UnknownVariableValue,
|
||||
Type: ast.TypeString,
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// Build the path to the child module we want
|
||||
path := make([]string, len(scope.Path), len(scope.Path)+1)
|
||||
copy(path, scope.Path)
|
||||
|
|
Loading…
Reference in New Issue