config: Rename "product" function to "setproduct"

This hopefully makes it clearer that it works with sets rather than real
numbers, avoiding confusion with "sum", "min", "max", etc.
This commit is contained in:
Martin Atkins 2019-01-14 17:48:12 -08:00
parent acd17d9075
commit 9d11d427a8
2 changed files with 10 additions and 10 deletions

View File

@ -118,7 +118,7 @@ func Funcs() map[string]ast.Function {
"min": interpolationFuncMin(), "min": interpolationFuncMin(),
"pathexpand": interpolationFuncPathExpand(), "pathexpand": interpolationFuncPathExpand(),
"pow": interpolationFuncPow(), "pow": interpolationFuncPow(),
"product": interpolationFuncProduct(), "setproduct": interpolationFuncSetProduct(),
"uuid": interpolationFuncUUID(), "uuid": interpolationFuncUUID(),
"replace": interpolationFuncReplace(), "replace": interpolationFuncReplace(),
"rsadecrypt": interpolationFuncRsaDecrypt(), "rsadecrypt": interpolationFuncRsaDecrypt(),
@ -1741,9 +1741,9 @@ func interpolationFuncRsaDecrypt() ast.Function {
} }
} }
// interpolationFuncProduct implements the "product" function // interpolationFuncSetProduct implements the "setproduct" function
// that returns the cartesian product of two or more lists // that returns the cartesian product of two or more lists or sets
func interpolationFuncProduct() ast.Function { func interpolationFuncSetProduct() ast.Function {
return ast.Function{ return ast.Function{
ArgTypes: []ast.Type{ast.TypeList}, ArgTypes: []ast.Type{ast.TypeList},
ReturnType: ast.TypeList, ReturnType: ast.TypeList,

View File

@ -2961,11 +2961,11 @@ H7CurtMwALQ/n/6LUKFmjRZjqbKX9SO2QSaC3grd6sY9Tu+bZjLe
}) })
} }
func TestInterpolateFuncProduct(t *testing.T) { func TestInterpolateFuncSetProduct(t *testing.T) {
testFunction(t, testFunctionConfig{ testFunction(t, testFunctionConfig{
Cases: []testFunctionCase{ Cases: []testFunctionCase{
{ {
`${product(list("dev", "qas", "prd"), list("applicationA", "applicationB", "applicationC"))}`, `${setproduct(list("dev", "qas", "prd"), list("applicationA", "applicationB", "applicationC"))}`,
[]interface{}{ []interface{}{
[]interface{}{"dev", "applicationA"}, []interface{}{"dev", "applicationA"},
[]interface{}{"dev", "applicationB"}, []interface{}{"dev", "applicationB"},
@ -2979,7 +2979,7 @@ func TestInterpolateFuncProduct(t *testing.T) {
false, false,
}, },
{ {
`${product(list("A", "B"), list("C", "D"), list("E", "F"))}`, `${setproduct(list("A", "B"), list("C", "D"), list("E", "F"))}`,
[]interface{}{ []interface{}{
[]interface{}{"A", "C", "E"}, []interface{}{"A", "C", "E"},
[]interface{}{"A", "C", "F"}, []interface{}{"A", "C", "F"},
@ -2993,19 +2993,19 @@ func TestInterpolateFuncProduct(t *testing.T) {
false, false,
}, },
{ {
`${product(list(), list(), list())}`, `${setproduct(list(), list(), list())}`,
nil, nil,
true, true,
}, },
{ {
`${product(list("foo"),list("bar"))}`, `${setproduct(list("foo"),list("bar"))}`,
[]interface{}{ []interface{}{
[]interface{}{"foo", "bar"}, []interface{}{"foo", "bar"},
}, },
false, false,
}, },
{ {
`${product(list("foo"))}`, `${setproduct(list("foo"))}`,
nil, nil,
true, true,
}, },