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

lang/funcs: Pass through empty list in chunklist #22119

Merged
merged 1 commit into from
Jul 18, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 4 additions & 0 deletions lang/funcs/collection.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions lang/funcs/collection_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1087,6 +1087,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 {
Expand Down