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

Arguments of type array cannot be access via index #3255

Closed
jtestard opened this issue Sep 18, 2020 · 23 comments
Closed

Arguments of type array cannot be access via index #3255

jtestard opened this issue Sep 18, 2020 · 23 comments
Assignees
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@jtestard
Copy link

jtestard commented Sep 18, 2020

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.

apiVersion: tekton.dev/v1beta1
kind: Pipeline
...
spec:
  params:
    - disabled:
        - 'false'
        - 'false'
        - 'false'
        - 'false'
...
  tasks:
    - name: ...
      params:
        - name: disabled
          value: '$(params.disabled[2])'

Actual Behavior

As can be seen here once the pipeline is run (seen through dashboard) , the variable is not substituted.
Screen Shot 2020-09-18 at 12 58 46 PM

Steps to Reproduce the Problem

Outlined above

Additional Info

  • Kubernetes version:

    Output of kubectl version:

Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.8", GitCommit:"211047e9a1922595eaa3a1127ed365e9299a6c23", GitTreeState:"clean", BuildDate:"2019-10-15T12:11:03Z", GoVersion:"go1.12.10", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"15+", GitVersion:"v1.15.12-gke.2", GitCommit:"fb7add51f767aae42655d39972210dc1c5dbd4b3", GitTreeState:"clean", BuildDate:"2020-06-01T22:20:10Z", GoVersion:"go1.12.17b4", Compiler:"gc", Platform:"linux/amd64"}
  • Tekton Pipeline version:

    Output of tkn version or kubectl get pods -n tekton-pipelines -l app=tekton-pipelines-controller -o=jsonpath='{.items[0].metadata.labels.version}'

Client version: 0.11.0
Pipeline version: v0.14.3
Triggers version: v0.7.0
@jtestard jtestard added the kind/bug Categorizes issue or PR as related to a bug. label Sep 18, 2020
@vdemeester
Copy link
Member

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

@jtestard
Copy link
Author

jtestard commented Sep 18, 2020

I noticed a typo indeed: the pipeline parameter name is disabled and matches that of the task parameter. Fixed.

@jtestard
Copy link
Author

jtestard commented Sep 21, 2020

@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?

@vdemeester
Copy link
Member

@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 🤔)

@ghost
Copy link

ghost commented Sep 21, 2020

I wonder if this needs a TEP or not

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?

@jtestard
Copy link
Author

@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

@ghost
Copy link

ghost commented Sep 21, 2020

So only adding index-based array access would be too incremental a change.

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.

@bobcatfish bobcatfish added kind/feature Categorizes issue or PR as related to a new feature. and removed kind/bug Categorizes issue or PR as related to a bug. labels Sep 24, 2020
@tekton-robot
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale with a justification.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Dec 23, 2020
@tekton-robot
Copy link
Collaborator

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten with a justification.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle rotten

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Jan 22, 2021
@ghost
Copy link

ghost commented Jan 22, 2021

/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.

@tekton-robot tekton-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jan 22, 2021
@jerop
Copy link
Member

jerop commented Jan 22, 2021

CEL Custom Tasks is now available and can be used for indexing and other array functions on parameters: https://github.com/tektoncd/experimental/tree/master/cel

Taking this example PipelineRun with contains and indexing:

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 CEL Custom Task produces evaluation Results that can be used in subsequent tasks:

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 😄

TEP: tektoncd/community#314

(note: CEL Custom Tasks is currently an experimental project)

@jerop
Copy link
Member

jerop commented Jan 22, 2021

Keeping this one alive because I think array params could still use some improvements like this to make them far more useful.

@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)

@ghost
Copy link

ghost commented Jan 22, 2021

@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 command or args list.

@tekton-robot
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale with a justification.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Apr 22, 2021
@tekton-robot
Copy link
Collaborator

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten with a justification.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle rotten

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels May 22, 2021
@ghost
Copy link

ghost commented Jun 15, 2021

@jtestard have you tried the CEL custom task that @jerop mentioned above? It doesn't directly handle tekton's concept of "array params" but you can pass it a stringified array and process it with CEL.

@bobcatfish bobcatfish self-assigned this Jul 15, 2021
@bobcatfish
Copy link
Collaborator

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

@tekton-robot tekton-robot removed the lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. label Jul 15, 2021
bobcatfish added a commit to bobcatfish/community that referenced this issue Jul 15, 2021
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)
bobcatfish added a commit to bobcatfish/community that referenced this issue Jul 15, 2021
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)
bobcatfish added a commit to bobcatfish/community that referenced this issue Aug 18, 2021
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)
bobcatfish added a commit to bobcatfish/community that referenced this issue Aug 18, 2021
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)
bobcatfish added a commit to bobcatfish/community that referenced this issue Aug 20, 2021
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)
bobcatfish added a commit to bobcatfish/community that referenced this issue Sep 9, 2021
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)
bobcatfish added a commit to bobcatfish/community that referenced this issue Sep 9, 2021
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)
@tekton-robot
Copy link
Collaborator

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale with a justification.
Stale issues rot after an additional 30d of inactivity and eventually close.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle stale

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Oct 15, 2021
@bobcatfish
Copy link
Collaborator

Want to keep this one open, still hoping to address this via TEP-0076

/remove-lifecycle stale

@tekton-robot
Copy link
Collaborator

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten with a justification.
Rotten issues close after an additional 30d of inactivity.
If this issue is safe to close now please do so with /close with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/lifecycle rotten

Send feedback to tektoncd/plumbing.

@tekton-robot tekton-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Nov 17, 2021
@bobcatfish
Copy link
Collaborator

Still happening I promise! 🙏

/remove-lifecycle stale

@tekton-robot
Copy link
Collaborator

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen with a justification.
Mark the issue as fresh with /remove-lifecycle rotten with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/close

Send feedback to tektoncd/plumbing.

@tekton-robot
Copy link
Collaborator

@tekton-robot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen with a justification.
Mark the issue as fresh with /remove-lifecycle rotten with a justification.
If this issue should be exempted, mark the issue as frozen with /lifecycle frozen with a justification.

/close

Send feedback to tektoncd/plumbing.

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.

bobcatfish added a commit to bobcatfish/community that referenced this issue Jan 26, 2022
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)
bobcatfish added a commit to bobcatfish/community that referenced this issue Jan 26, 2022
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)
bobcatfish added a commit to bobcatfish/community that referenced this issue Feb 2, 2022
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)
bobcatfish added a commit to bobcatfish/community that referenced this issue Feb 4, 2022
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)
tekton-robot pushed a commit to tektoncd/community that referenced this issue Feb 14, 2022
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/feature Categorizes issue or PR as related to a new feature. lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

5 participants