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

CEL support in PipelineRun Task params values #8416

Open
say5 opened this issue Dec 5, 2024 · 4 comments
Open

CEL support in PipelineRun Task params values #8416

say5 opened this issue Dec 5, 2024 · 4 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@say5
Copy link
Contributor

say5 commented Dec 5, 2024

Feature request

Support CEL in PipelineRun Task params values (and matrix values).

Use case

Imagine we have a Pipeline cel-use-case with one task payload, this Pipeline has 3 params: a, b and c. Task payload has only one param - destination. Now, depending on value of a we should supply b or c to payload task. Currently it can be done like this:

Option A - using when:

apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: cel-use-case
spec:
  params:
  - a
  - b
  - c
  tasks:
  - name: payload-b
    params:
    - name: destination
      value: $(params.b)
    when:
    - input: "$(params.a)"
      operator: in
      values: ["b"]

  - name: payload-c
    params:
    - name: destination
      value: $(params.c)
    when:
    - input: "$(params.a)"
      operator: in
      values: ["c"]

Option B - using mutation pre-task:

apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: cel-use-case
spec:
  params:
  - a
  - b
  - c
  tasks:
  - name: mutation
    taskSpec:
      results:
      - name: destination
        type: string
      steps:
      - name: mutate
        image: bash
        command: ["bash", "-c"]
        args:
        - |
          if [ "$(params.a)" = "b" ]; then
            echo -n "$(params.b)" > $(results.destination.path)
          else
            echo -n "$(params.c)" > $(results.destination.path)
          fi

  - name: payload
    runAfter:
    - mutation
    params:
    - name: destination
      value: $(tasks.mutation.results.destination)

Now, if we have CEL support it can be done like this:

apiVersion: tekton.dev/v1
kind: Pipeline
metadata:
  name: cel-use-case
spec:
  params:
  - a
  - b
  - c
  tasks:
  - name: payload
    params:
    - name: destination
      cel: "'$(params.a)' == 'b' ? '$(params.b)' : '$(params.c)'"
@say5 say5 added the kind/feature Categorizes issue or PR as related to a new feature. label Dec 5, 2024
@HAMEDwwwGmildotcom

This comment was marked as spam.

@HAMEDwwwGmildotcom

This comment was marked as spam.

@HAMEDwwwGmildotcom

This comment was marked as spam.

@HAMEDwwwGmildotcom

This comment was marked as spam.

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.
Projects
None yet
Development

No branches or pull requests

2 participants