-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Substitute params by index #3044
Comments
Related issue: #1393 <-- in that issue I believe @skaegi is suggesting a broader syntax for accessing param values (i think jsonpath based?) I think we could totally tackle the features one at a time if that's easiest, as long as they are all headed in the same direction - and afaik the syntax above is how array access would look? might be worth bringing up in the API wg too: https://github.com/tektoncd/community/blob/master/working-groups.md#api |
I added the example with array types. It is just using bracket annotation instead of dot annotation. However, with bracket annotation we can use the type to distinguish index(int)/key(string). |
Quick and Dirty POC: https://github.com/popcor255/pipeline/tree/replace-by-index-without-validation apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: simple-task
spec:
params:
- name: param
type: string
steps:
- name: alpine
image: alpine
command: [ "echo" ]
args: [ "$(params.0)" ] |
The main issue I am trying to highlight is that an apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: sleepy-with-nested-params
spec:
params:
- name: myParams
type: array
steps:
- name: alpine
image: alpine
command: [ "echo" ]
args: [ "$(params.myParams[*])" ]
---
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
generateName: run-with-sleepy-with-nested-params
spec:
taskRef:
name: sleepy-with-nested-params
params:
- name: myParams
value:
- "test=testing"
- "env=test" apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: sleepy-with-psuedo-params
spec:
params:
- name: test
- name: env
steps:
- name: alpine
image: alpine
command: [ "echo" ]
args: [ "$(params[*])" ]
---
apiVersion: tekton.dev/v1beta1
kind: TaskRun
metadata:
generateName: run-with-sleepy-with-psuedo-params
spec:
taskRef:
name: sleepy-with-psuedo-params
params:
- name: test
value: testing
- name: env
value: testing |
#1020 |
Feature request
Currently prams can be substituted by key (string substitute). However, params is an array of type param. I would like to reference a parameter by the index in the params array rather than the key.
TLDR;
Array of Type Params
is not the same asParam that is Type Array
. We should probably fix this.(how array access would look)
Request:
The above tasks should produce the same result as these tasks:
These two tasks should produce the same result.
Note : This implementation requires indexes to be declared before runtime.
The text was updated successfully, but these errors were encountered: