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(),
"pathexpand": interpolationFuncPathExpand(),
"pow": interpolationFuncPow(),
"product": interpolationFuncProduct(),
"setproduct": interpolationFuncSetProduct(),
"uuid": interpolationFuncUUID(),
"replace": interpolationFuncReplace(),
"rsadecrypt": interpolationFuncRsaDecrypt(),
@ -1741,9 +1741,9 @@ func interpolationFuncRsaDecrypt() ast.Function {
}
}
// interpolationFuncProduct implements the "product" function
// that returns the cartesian product of two or more lists
func interpolationFuncProduct() ast.Function {
// interpolationFuncSetProduct implements the "setproduct" function
// that returns the cartesian product of two or more lists or sets
func interpolationFuncSetProduct() ast.Function {
return ast.Function{
ArgTypes: []ast.Type{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{
Cases: []testFunctionCase{
{
`${product(list("dev", "qas", "prd"), list("applicationA", "applicationB", "applicationC"))}`,
`${setproduct(list("dev", "qas", "prd"), list("applicationA", "applicationB", "applicationC"))}`,
[]interface{}{
[]interface{}{"dev", "applicationA"},
[]interface{}{"dev", "applicationB"},
@ -2979,7 +2979,7 @@ func TestInterpolateFuncProduct(t *testing.T) {
false,
},
{
`${product(list("A", "B"), list("C", "D"), list("E", "F"))}`,
`${setproduct(list("A", "B"), list("C", "D"), list("E", "F"))}`,
[]interface{}{
[]interface{}{"A", "C", "E"},
[]interface{}{"A", "C", "F"},
@ -2993,19 +2993,19 @@ func TestInterpolateFuncProduct(t *testing.T) {
false,
},
{
`${product(list(), list(), list())}`,
`${setproduct(list(), list(), list())}`,
nil,
true,
},
{
`${product(list("foo"),list("bar"))}`,
`${setproduct(list("foo"),list("bar"))}`,
[]interface{}{
[]interface{}{"foo", "bar"},
},
false,
},
{
`${product(list("foo"))}`,
`${setproduct(list("foo"))}`,
nil,
true,
},