-
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
Arguments of type array cannot be access via index #3255
Comments
Hey @jtestard, thx for the issue. I think it's not clearly documented in here, but we do not currently support accessing array values by index. /cc @skaegi @bobcatfish |
I noticed a typo indeed: the pipeline parameter name is |
@vdemeester We are using Tekton in production at our startup, pretty eager on the tech. However, this (among other things) is a blocker to get us where we want to be. Is this the kind of issue an external contributor (us) could easily tackle could get things going faster? |
@jtestard sure 😉 I wonder if this needs a TEP or not (my guess is that we may not but… it's kinda user-facing 🤔) |
I think it's probably a good idea. We've had other proposals for this problem that suggest a more wide-ranging solution (see the JSONPath work @skaegi started for instance here and, related, here). And we've had similar requests asking for CEL. So there's been some different proposals. It seems like a good idea, if we're going to expand our variable access features, to write something up and talk it through as a community. WDYT? |
@sbwsg So only adding index-based array access would be too incremental a change. I don't know if we have the resources on our end to assist with adding support for a whole new language such as JSONPath/CEL. Let us know if/how we can help |
Ah, that wasn't quite what I was trying to suggest, sorry. I agree with what @vdemeester suggested: this is a user-facing change. And this is an area that's had people propose changes to it in the past. So, given it's user-facing and we've got other folks in the community who are interested in this area, I think that writing up a short TEP to declare the change you're proposing is the way to go. For what it's worth I think the incremental improvement is a good idea. But I just want to make sure it gets surfaced to the right folks before we commit to it getting implemented and merged. |
Issues go stale after 90d of inactivity. /lifecycle stale Send feedback to tektoncd/plumbing. |
Stale issues rot after 30d of inactivity. /lifecycle rotten Send feedback to tektoncd/plumbing. |
/remove-lifecycle rotten Keeping this one alive because I think array params could still use some improvements like this to make them far more useful. |
Taking this example apiVersion: tekton.dev/v1beta1
kind: PipelineRun
metadata:
generateName: pr-indexing-
spec:
pipelineSpec:
params:
- name: alpha
type: string
tasks:
- name: indexing
taskRef:
apiVersion: cel.tekton.dev/v1alpha1
kind: CEL
params:
- name: c-exists
value: "'c' in $(params.alpha)"
- name: at-index-1
value: "$(params.alpha)[1]"
params:
- name: alpha
value: "['a', 'b', 'c']" When executed, the Name: pr-indexing-d47gj
Namespace: default
API Version: tekton.dev/v1beta1
Kind: PipelineRun
Metadata:
Creation Timestamp: 2021-01-22T16:13:22Z
Generate Name: pr-indexing-
# […]
Status:
Completion Time: 2021-01-22T16:13:22Z
Conditions:
Last Transition Time: 2021-01-22T16:13:22Z
Message: Tasks Completed: 1 (Failed: 0, Cancelled 0), Skipped: 0
Reason: Succeeded
Status: True
Type: Succeeded
Pipeline Spec:
# […]
Runs:
pr-indexing-d47gj-indexing-2t9vr:
Pipeline Task Name: indexing
Status:
Completion Time: 2021-01-22T16:13:22Z
Conditions:
Last Transition Time: 2021-01-22T16:13:22Z
Message: CEL expressions were evaluated successfully
Reason: EvaluationSuccess
Status: True
Type: Succeeded
Extra Fields: <nil>
Observed Generation: 1
Results:
Name: c-exists
Value: true
Name: at-index-1
Value: b
Start Time: 2021-01-22T16:13:22Z
Start Time: 2021-01-22T16:13:22Z
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal Started 12s PipelineRun
Normal Running 12s PipelineRun Tasks Completed: 0 (Failed: 0, Cancelled 0), Incomplete: 1, Skipped: 0
Normal Succeeded 12s PipelineRun Tasks Completed: 1 (Failed: 0, Cancelled 0), Skipped: 0
@jtestard if you use this, please share any feedback on your experience and how we can make it better 😄 (note: |
@sbwsg another alternative we could consider, if CEL custom tasks is promoted from experimental, is deprecating array params and supporting string params only for simplicity and flexibility (avoiding to implement our own expression syntax) |
Very interesting! I agree this would solve a lot of different problems we have with the existing array syntax's complexity and offer flexibility on syntax choice / behaviour. I wonder how we could handle situations where a user passes an array of varying length and this needs to be merged / appended to a Step's |
Issues go stale after 90d of inactivity. /lifecycle stale Send feedback to tektoncd/plumbing. |
Stale issues rot after 30d of inactivity. /lifecycle rotten Send feedback to tektoncd/plumbing. |
I'm creating a proposal to add specifically support for indexing into arrays; however I'm limiting the proposal to that so if we want to talk about full JSONPath (or even CEL) support that would have to be a separate proposal. /remove-lifecycle rotten |
This TEP proposes adding more support for array params by adding array results as well as the ability to index into arrays. It refers to TEP-0075 which will be added in a separate commit, which proposes adding support for dictionary types. Related issues: * [pipelines#1393 Consider removing type from params (or _really_ support types)](tektoncd/pipeline#1393) * [pipelines#3255 Arguments of type array cannot be access via index](tektoncd/pipeline#3255)
This TEP proposes adding more support for array params by adding array results as well as the ability to index into arrays. It refers to TEP-0075 which will be added in a separate commit, which proposes adding support for dictionary types. Related issues: * [pipelines#1393 Consider removing type from params (or _really_ support types)](tektoncd/pipeline#1393) * [pipelines#3255 Arguments of type array cannot be access via index](tektoncd/pipeline#3255)
This TEP proposes adding more support for array params by adding array results as well as the ability to index into arrays. It refers to TEP-0075 which will be added in a separate commit, which proposes adding support for dictionary types. Related issues: * [pipelines#1393 Consider removing type from params (or _really_ support types)](tektoncd/pipeline#1393) * [pipelines#3255 Arguments of type array cannot be access via index](tektoncd/pipeline#3255)
This TEP proposes adding more support for array params by adding array results as well as the ability to index into arrays. It refers to TEP-0075 which will be added in a separate commit, which proposes adding support for dictionary types. Related issues: * [pipelines#1393 Consider removing type from params (or _really_ support types)](tektoncd/pipeline#1393) * [pipelines#3255 Arguments of type array cannot be access via index](tektoncd/pipeline#3255)
This TEP proposes adding more support for array params by adding array results as well as the ability to index into arrays. It refers to TEP-0075 which will be added in a separate commit, which proposes adding support for dictionary types. Related issues: * [pipelines#1393 Consider removing type from params (or _really_ support types)](tektoncd/pipeline#1393) * [pipelines#3255 Arguments of type array cannot be access via index](tektoncd/pipeline#3255)
This TEP proposes adding more support for array params by adding array results as well as the ability to index into arrays. It refers to TEP-0075 which will be added in a separate commit, which proposes adding support for dictionary types. Related issues: * [pipelines#1393 Consider removing type from params (or _really_ support types)](tektoncd/pipeline#1393) * [pipelines#3255 Arguments of type array cannot be access via index](tektoncd/pipeline#3255)
This TEP proposes adding more support for array params by adding array results as well as the ability to index into arrays. It refers to TEP-0075 which will be added in a separate commit, which proposes adding support for dictionary types. Related issues: * [pipelines#1393 Consider removing type from params (or _really_ support types)](tektoncd/pipeline#1393) * [pipelines#3255 Arguments of type array cannot be access via index](tektoncd/pipeline#3255)
Issues go stale after 90d of inactivity. /lifecycle stale Send feedback to tektoncd/plumbing. |
Want to keep this one open, still hoping to address this via TEP-0076 /remove-lifecycle stale |
Stale issues rot after 30d of inactivity. /lifecycle rotten Send feedback to tektoncd/plumbing. |
Still happening I promise! 🙏 /remove-lifecycle stale |
Rotten issues close after 30d of inactivity. /close Send feedback to tektoncd/plumbing. |
@tekton-robot: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
This TEP proposes adding more support for array params by adding array results as well as the ability to index into arrays. It refers to TEP-0075 which will be added in a separate commit, which proposes adding support for dictionary types. Related issues: * [pipelines#1393 Consider removing type from params (or _really_ support types)](tektoncd/pipeline#1393) * [pipelines#3255 Arguments of type array cannot be access via index](tektoncd/pipeline#3255)
This TEP proposes adding more support for array params by adding array results as well as the ability to index into arrays. It refers to TEP-0075 which will be added in a separate commit, which proposes adding support for dictionary types. Related issues: * [pipelines#1393 Consider removing type from params (or _really_ support types)](tektoncd/pipeline#1393) * [pipelines#3255 Arguments of type array cannot be access via index](tektoncd/pipeline#3255)
This TEP proposes adding more support for array params by adding array results as well as the ability to index into arrays. It refers to TEP-0075 which will be added in a separate commit, which proposes adding support for dictionary types. Related issues: * [pipelines#1393 Consider removing type from params (or _really_ support types)](tektoncd/pipeline#1393) * [pipelines#3255 Arguments of type array cannot be access via index](tektoncd/pipeline#3255)
This TEP proposes adding more support for array params by adding array results as well as the ability to index into arrays. It refers to TEP-0075 which will be added in a separate commit, which proposes adding support for dictionary types. Related issues: * [pipelines#1393 Consider removing type from params (or _really_ support types)](tektoncd/pipeline#1393) * [pipelines#3255 Arguments of type array cannot be access via index](tektoncd/pipeline#3255)
This TEP proposes adding more support for array params by adding array results as well as the ability to index into arrays. It refers to TEP-0075 which will be added in a separate commit, which proposes adding support for dictionary types. Related issues: * [pipelines#1393 Consider removing type from params (or _really_ support types)](tektoncd/pipeline#1393) * [pipelines#3255 Arguments of type array cannot be access via index](tektoncd/pipeline#3255)
Expected Behavior
When using a parameter of type
Array
and trying to access access a specific index, the variable substitution does not occur. Assuming the following pipeline spec, I would expect the tasks generated to have the value'false'
be substituted.Actual Behavior
As can be seen here once the pipeline is run (seen through dashboard) , the variable is not substituted.
Steps to Reproduce the Problem
Outlined above
Additional Info
Kubernetes version:
Output of
kubectl version
:Tekton Pipeline version:
Output of
tkn version
orkubectl get pods -n tekton-pipelines -l app=tekton-pipelines-controller -o=jsonpath='{.items[0].metadata.labels.version}'
The text was updated successfully, but these errors were encountered: