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

pkg/apis: remove duplicate substitution code. #3579

Merged
merged 1 commit into from
Dec 1, 2020
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: 2 additions & 2 deletions pkg/apis/pipeline/v1beta1/param_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,11 +120,11 @@ func (arrayOrString ArrayOrString) MarshalJSON() ([]byte, error) {
// ApplyReplacements applyes replacements for ArrayOrString type
func (arrayOrString *ArrayOrString) ApplyReplacements(stringReplacements map[string]string, arrayReplacements map[string][]string) {
if arrayOrString.Type == ParamTypeString {
arrayOrString.StringVal = ApplyReplacements(arrayOrString.StringVal, stringReplacements)
arrayOrString.StringVal = substitution.ApplyReplacements(arrayOrString.StringVal, stringReplacements)
} else {
var newArrayVal []string
for _, v := range arrayOrString.ArrayVal {
newArrayVal = append(newArrayVal, ApplyArrayReplacements(v, stringReplacements, arrayReplacements)...)
newArrayVal = append(newArrayVal, substitution.ApplyArrayReplacements(v, stringReplacements, arrayReplacements)...)
}
arrayOrString.ArrayVal = newArrayVal
}
Expand Down
139 changes: 0 additions & 139 deletions pkg/apis/pipeline/v1beta1/substitution.go

This file was deleted.

5 changes: 3 additions & 2 deletions pkg/apis/pipeline/v1beta1/when_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1beta1

import (
"github.com/tektoncd/pipeline/pkg/substitution"
"k8s.io/apimachinery/pkg/selection"
)

Expand Down Expand Up @@ -102,11 +103,11 @@ func (we *WhenExpression) hasVariable() bool {
}

func (we *WhenExpression) applyReplacements(replacements map[string]string) WhenExpression {
replacedInput := ApplyReplacements(we.GetInput(), replacements)
replacedInput := substitution.ApplyReplacements(we.GetInput(), replacements)

var replacedValues []string
for _, val := range we.GetValues() {
replacedValues = append(replacedValues, ApplyReplacements(val, replacements))
replacedValues = append(replacedValues, substitution.ApplyReplacements(val, replacements))
}

return WhenExpression{Input: replacedInput, Operator: we.GetOperator(), Values: replacedValues}
Expand Down