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

[release-v0.37.x] Fix the issue with empty array replacement #5394

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
1 change: 1 addition & 0 deletions pkg/apis/pipeline/paths.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const (
HomeDir = "/tekton/home"
// CredsDir is the directory where credentials are placed to meet the legacy credentials
// helpers image (aka "creds-init") contract
// #nosec
CredsDir = "/tekton/creds"
// StepsDir is the directory used for a step to store any metadata related to the step
StepsDir = "/tekton/steps"
Expand Down
2 changes: 1 addition & 1 deletion pkg/apis/pipeline/v1beta1/param_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ func (arrayOrString *ArrayOrString) ApplyReplacements(stringReplacements map[str
if arrayOrString.Type == ParamTypeString {
arrayOrString.StringVal = substitution.ApplyReplacements(arrayOrString.StringVal, stringReplacements)
} else {
var newArrayVal []string
newArrayVal := []string{}
for _, v := range arrayOrString.ArrayVal {
newArrayVal = append(newArrayVal, substitution.ApplyArrayReplacements(v, stringReplacements, arrayReplacements)...)
}
Expand Down
13 changes: 12 additions & 1 deletion pkg/apis/pipeline/v1beta1/param_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,18 @@ func TestArrayOrString_ApplyReplacements(t *testing.T) {
},
expectedOutput: v1beta1.NewArrayOrString("firstvalue", "array", "value", "lastvalue", "asdf", "sdfsd"),
}, {
name: "empty array replacement",
name: "empty array replacement without extra elements",
args: args{
// input: v1beta1.NewArrayOrString("$(arraykey)"),
input: &v1beta1.ArrayOrString{
Type: v1beta1.ParamTypeArray,
ArrayVal: []string{"$(arraykey)"},
},
arrayReplacements: map[string][]string{"arraykey": {}},
},
expectedOutput: &v1beta1.ArrayOrString{Type: v1beta1.ParamTypeArray, ArrayVal: []string{}},
}, {
name: "empty array replacement with extra elements",
args: args{
input: v1beta1.NewArrayOrString("firstvalue", "$(arraykey)", "lastvalue"),
stringReplacements: map[string]string{"some": "value", "anotherkey": "value"},
Expand Down
1 change: 1 addition & 0 deletions pkg/pod/creds_init.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import (
)

const (
// #nosec
credsInitHomeMountPrefix = "tekton-creds-init-home"
sshKnownHosts = "known_hosts"
)
Expand Down