diff --git a/pkg/apis/pipeline/v1/matrix_types.go b/pkg/apis/pipeline/v1/matrix_types.go index 6ae8142a9b2..8c18f917dc3 100644 --- a/pkg/apis/pipeline/v1/matrix_types.go +++ b/pkg/apis/pipeline/v1/matrix_types.go @@ -72,7 +72,7 @@ func (m *Matrix) FanOut() []Params { for _, parameter := range m.Params { combinations = combinations.fanOutMatrixParams(parameter) } - combinations = combinations.overwriteCombinations(includeCombinations) + combinations.overwriteCombinations(includeCombinations) combinations = combinations.addNewCombinations(includeCombinations) return combinations.toParams() } @@ -84,7 +84,11 @@ func (cs Combinations) overwriteCombinations(ics Combinations) Combinations { for _, paramCombination := range cs { for _, includeCombination := range ics { if paramCombination.contains(includeCombination) { - includeCombination.overwrite(paramCombination) + // overwrite the parameter name and value in existing combination + // with the include combination + for name, val := range includeCombination { + paramCombination[name] = val + } } } } @@ -115,14 +119,6 @@ func (c Combination) contains(includeCombination Combination) bool { return true } -// overwrite the parameter name and value exists in combination with the include combination -func (c Combination) overwrite(oldCombination Combination) Combination { - for name, val := range c { - oldCombination[name] = val - } - return oldCombination -} - // shouldAddNewCombination returns true if the include parameter name exists but the value is // missing from combinations func (cs Combinations) shouldAddNewCombination(includeCombination map[string]string) bool { diff --git a/pkg/apis/pipeline/v1beta1/matrix_types.go b/pkg/apis/pipeline/v1beta1/matrix_types.go index 9b322fe6084..5c67de4e979 100644 --- a/pkg/apis/pipeline/v1beta1/matrix_types.go +++ b/pkg/apis/pipeline/v1beta1/matrix_types.go @@ -72,7 +72,7 @@ func (m *Matrix) FanOut() []Params { for _, parameter := range m.Params { combinations = combinations.fanOutMatrixParams(parameter) } - combinations = combinations.overwriteCombinations(includeCombinations) + combinations.overwriteCombinations(includeCombinations) combinations = combinations.addNewCombinations(includeCombinations) return combinations.toParams() } @@ -84,7 +84,11 @@ func (cs Combinations) overwriteCombinations(ics Combinations) Combinations { for _, paramCombination := range cs { for _, includeCombination := range ics { if paramCombination.contains(includeCombination) { - includeCombination.overwrite(paramCombination) + // overwrite the parameter name and value in existing combination + // with the include combination + for name, val := range includeCombination { + paramCombination[name] = val + } } } } @@ -115,14 +119,6 @@ func (c Combination) contains(includeCombination Combination) bool { return true } -// overwrite the parameter name and value exists in combination with the include combination -func (c Combination) overwrite(oldCombination Combination) Combination { - for name, val := range c { - oldCombination[name] = val - } - return oldCombination -} - // shouldAddNewCombination returns true if the include parameter name exists but the value is // missing from combinations func (cs Combinations) shouldAddNewCombination(includeCombination map[string]string) bool {