Skip to content

Commit

Permalink
interpolation strings were beeing validated
Browse files Browse the repository at this point in the history
Interpolation strings for non-computed values in a list were being
passed to the schema's ValidateFunc.
  • Loading branch information
jbardin committed Mar 24, 2017
1 parent 6a13d70 commit 99a12f5
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions helper/schema/schema_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"reflect"
"sort"
"strconv"
"strings"
"testing"

"github.com/hashicorp/hil"
Expand Down Expand Up @@ -4924,6 +4925,47 @@ func TestSchemaMap_Validate(t *testing.T) {
},
Err: true,
},

// The Validation function should not see interpolation strings from
// non-computed values.
"set with partially computed list and map": {
Schema: map[string]*Schema{
"outer": &Schema{
Type: TypeSet,
Optional: true,
Computed: true,
Elem: &Resource{
Schema: map[string]*Schema{
"list": &Schema{
Type: TypeList,
Optional: true,
Elem: &Schema{
Type: TypeString,
ValidateFunc: func(v interface{}, k string) (ws []string, es []error) {
if strings.HasPrefix(v.(string), "${") {
es = append(es, fmt.Errorf("should not have interpolations"))
}
return
},
},
},
},
},
},
},
Config: map[string]interface{}{
"outer": []map[string]interface{}{
{
"list": []interface{}{"${var.a}", "${var.b}", "c"},
},
},
},
Vars: map[string]string{
"var.a": "A",
"var.b": config.UnknownVariableValue,
},
Err: false,
},
}

for tn, tc := range cases {
Expand Down

0 comments on commit 99a12f5

Please sign in to comment.