Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reify the list values before validation #13046

Merged
merged 2 commits into from
Mar 24, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
interpolation strings were beeing validated
Interpolation strings for non-computed values in a list were being
passed to the schema's ValidateFunc.
jbardin committed Mar 24, 2017
commit 99a12f5df30acd8afaf00e2328d8870abcaad301
42 changes: 42 additions & 0 deletions helper/schema/schema_test.go
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@ import (
"reflect"
"sort"
"strconv"
"strings"
"testing"

"github.com/hashicorp/hil"
@@ -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 {