Skip to content

feature: Support boolean parameter or that a string parameter is converted into a boolean #8697

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

Open
cmoulliard opened this issue Apr 10, 2025 · 0 comments
Labels
kind/feature Categorizes issue or PR as related to a new feature.

Comments

@cmoulliard
Copy link

cmoulliard commented Apr 10, 2025

Feature request

Support boolean parameter or that a string parameter is converted into a boolean. Ideally we should have a collection of functions able to perform $(params.PRIVILEGED | toBoolean)

Use case

Tekton don't propose a way to define a boolean parameter or to convert a string parameter to a boolean as this is needed to configure the following field: pod > securityContext > privileged: true

The only working solution implied to duplicate the code of the task which is a bit boring and to use when

Example:

apiVersion: tekton.dev/v1
kind: PipelineRun
metadata:
  name: pr-echo
spec:
  params:
    - name: HELLO
      value: "Hello World!"
    - name: BYE
      value: "Bye World!"
    - name: PRIVILEGED
      value: false
  pipelineSpec:
    tasks:
      - name: echo-privileged-true
        when:
          - input: "$(params.PRIVILEGED)"
            operator: in
            values: [ "true" ]
        taskSpec:
          steps:
            - name: echo-privileged-true
              image: ubuntu
              script: |
                #!/usr/bin/env bash
                
                echo "The value of the param PRIVILEGED is: $(params.PRIVILEGED)"
                echo "$(params.HELLO)"
              securityContext:
                privileged: true

      - name: echo-privileged-false
        when:
          - input: "$(params.PRIVILEGED)"
            operator: in
            values: [ "false" ]
        taskSpec:
          steps:
            - name: echo-privileged-false
              image: ubuntu
              script: |
                #!/usr/bin/env bash
                
                echo "The value of the param PRIVILEGED is: $(params.PRIVILEGED)"
                echo "$(params.HELLO)"
              securityContext:
                privileged: false
@cmoulliard cmoulliard added the kind/feature Categorizes issue or PR as related to a new feature. label Apr 10, 2025
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
Status: Todo
Development

No branches or pull requests

1 participant