Merge pull request #22119 from hashicorp/b-chunklist-empty-list

lang/funcs: Pass through empty list in chunklist
This commit is contained in:
Radek Simko 2019-07-18 20:59:47 +01:00 committed by GitHub
commit 5c30bafee0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 0 deletions

View File

@ -392,6 +392,10 @@ var ChunklistFunc = function.New(&function.Spec{
return cty.UnknownVal(retType), nil
}
if listVal.LengthInt() == 0 {
return cty.ListValEmpty(listVal.Type()), nil
}
var size int
err = gocty.FromCtyValue(args[1], &size)
if err != nil {

View File

@ -1097,6 +1097,12 @@ func TestChunklist(t *testing.T) {
cty.UnknownVal(cty.List(cty.List(cty.String))),
false,
},
{
cty.ListValEmpty(cty.String),
cty.NumberIntVal(3),
cty.ListValEmpty(cty.List(cty.String)),
false,
},
}
for i, test := range tests {