Skip to content

Commit

Permalink
Manual cherry-pick to avoid conflict with step-params
Browse files Browse the repository at this point in the history
Fix: Identify workspace usage in a Task

Prior to this, when identifying whether a Task used a workspace,
we limited the check to command, args and scripts in steps,
stepTemplates and sidecars. However, the workspace path could also
be used as a param to a StepAction or env cariables in steps and
sidecars and also workingDirs. This PR fixes that.

Fixes tektoncd#8008.
  • Loading branch information
chitrangpatel committed Jun 4, 2024
1 parent 3d3b942 commit 1393915
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
7 changes: 0 additions & 7 deletions pkg/workspace/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -250,13 +250,6 @@ func findWorkspaceSubstitutionLocationsInSteps(steps []v1.Step) sets.String {
for _, e := range step.Env {
locationsToCheck.Insert(e.Value)
}
for _, p := range step.Params {
locationsToCheck.Insert(p.Value.ArrayVal...)
for k := range p.Value.ObjectVal {
locationsToCheck.Insert(p.Value.ObjectVal[k])
}
locationsToCheck.Insert(p.Value.StringVal)
}
}
return locationsToCheck
}
Expand Down
17 changes: 0 additions & 17 deletions pkg/workspace/apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1254,23 +1254,6 @@ func TestFindWorkspacesUsedByTask(t *testing.T) {
want: sets.NewString(
"shared",
),
}, {
name: "workspace used in step Params for stepactions",
ts: &v1.TaskSpec{
Steps: []v1.Step{{
Name: "step-name",
Params: []v1.Param{{
Name: "path",
Value: *v1.NewStructuredValues("$(workspaces.shared.path)"),
}},
Ref: &v1.Ref{
Name: "step-action",
},
}},
},
want: sets.NewString(
"shared",
),
}, {
name: "workspace used in sidecar env",
ts: &v1.TaskSpec{
Expand Down

0 comments on commit 1393915

Please sign in to comment.