Skip to content

Commit

Permalink
Add support for params between Step and StepActions
Browse files Browse the repository at this point in the history
Following the previous [PR](tektoncd#7317), which introduced Params to the `StepAction` CRD,
this PR integrates `param` usage between `Steps` and `StepActions`. This
completes support for params in `StepActions`. This work is part of
issue tektoncd#7259.
  • Loading branch information
chitrangpatel committed Nov 8, 2023
1 parent 15c8168 commit c6958c9
Show file tree
Hide file tree
Showing 10 changed files with 929 additions and 23 deletions.
67 changes: 67 additions & 0 deletions examples/v1/pipelineruns/alpha/stepaction-params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
apiVersion: tekton.dev/v1alpha1
kind: StepAction
metadata:
name: step-action
spec:
params:
- name: string-param
default: "a string param"
- name: array-param
type: array
default:
- an
- array
- param
- name: object-param
type: object
properties:
key1:
type: string
key2:
type: string
key3:
type: string
default:
key1: "step-action default key1"
key2: "step-action default key2"
key3: "step-action default key3"
image: bash:3.2
args: [
"echo",
"$(params.array-param[*])",
"$(params.string-param)",
"$(params.object-param.key1)",
"$(params.object-param.key2)"
]
---
apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
name: step-action-pipeline-run-propagated
spec:
params:
- name: stringparam
value: "pipelinerun stringparam"
- name: arrayparam
value:
- "pipelinerun"
- "array"
- "param"
- name: objectparam
value:
key2: "pipelinerun key2"
PipelineSpec:
tasks:
- name: run-action
taskSpec:
steps:
- name: action-runner
ref:
name: step-action
params:
- name: string-param
value: $(params.stringparam)
- name: array-param
value: $(params.arrayparam[*])
- name: object-param
value: $(params.objectparam[*])
75 changes: 75 additions & 0 deletions examples/v1/taskruns/alpha/stepaction-params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
apiVersion: tekton.dev/v1alpha1
kind: StepAction
metadata:
name: step-action
spec:
params:
- name: string-param
default: "a string param"
- name: array-param
type: array
default:
- an
- array
- param
- name: object-param
type: object
properties:
key1:
type: string
key2:
type: string
key3:
type: string
default:
key1: "step-action default key1"
key2: "step-action default key2"
key3: "step-action default key3"
image: bash:3.2
args: [
"echo",
"$(params.array-param[*])",
"$(params.string-param)",
"$(params.object-param.key1)",
"$(params.object-param.key2)",
"$(params.object-param.key3)"
]
---
apiVersion: tekton.dev/v1
kind: TaskRun
metadata:
name: step-action-run
spec:
params:
- name: stringparam
value: "taskrun stringparam"
- name: arrayparam
value:
- "taskrun"
- "array"
- "param"
- name: objectparam
value:
key2: "taksrun key2"
TaskSpec:
params:
- name: objectparam
properties:
key1:
type: string
key2:
type: string
default:
key1: "taskspec default key1"
key2: "taskspec default key2"
steps:
- name: action-runner
ref:
name: step-action
params:
- name: string-param
value: $(params.stringparam)
- name: array-param
value: $(params.arrayparam[*])
- name: object-param
value: $(params.objectparam[*])
6 changes: 3 additions & 3 deletions pkg/reconciler/pipelinerun/resources/apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -367,9 +367,9 @@ func propagateParams(t v1.PipelineTask, stringReplacements map[string]string, ar
}
}
}
t.TaskSpec.TaskSpec = *resources.ApplyReplacements(&t.TaskSpec.TaskSpec, stringReplacementsDup, arrayReplacementsDup)
t.TaskSpec.TaskSpec = *resources.ApplyReplacements(&t.TaskSpec.TaskSpec, stringReplacementsDup, arrayReplacementsDup, objectReplacementsDup)
} else {
t.TaskSpec.TaskSpec = *resources.ApplyReplacements(&t.TaskSpec.TaskSpec, stringReplacements, arrayReplacements)
t.TaskSpec.TaskSpec = *resources.ApplyReplacements(&t.TaskSpec.TaskSpec, stringReplacements, arrayReplacements, objectReplacements)
}
return t
}
Expand All @@ -395,7 +395,7 @@ func PropagateResults(rpt *ResolvedPipelineTask, runStates PipelineRunState) {
}
}
}
rpt.ResolvedTask.TaskSpec = resources.ApplyReplacements(rpt.ResolvedTask.TaskSpec, stringReplacements, arrayReplacements)
rpt.ResolvedTask.TaskSpec = resources.ApplyReplacements(rpt.ResolvedTask.TaskSpec, stringReplacements, arrayReplacements, map[string]map[string]string{})
}

// ApplyTaskResultsToPipelineResults applies the results of completed TasksRuns and Runs to a Pipeline's
Expand Down
Loading

0 comments on commit c6958c9

Please sign in to comment.