IBM / tekton-lint

Linter for Tekton definitions.
Apache License 2.0
27 stars 16 forks source link

Report missing parameter in TaskSpec (inline tasks) #61

Open necccc opened 3 years ago

necccc commented 3 years ago

In 0.5.2 we should report missing parameters in taskSpec tasks

Example:


    - name: inline-task
      params:
        - name: pipeline-debug
          value: $(params.pipeline-debug)
      workspaces:
        - name: secrets
          workspace: artifacts
      taskSpec:
        workspaces:
          - name: secrets
            mountPath: /secrets
        params:
          - name: pipeline-debug
        stepTemplate:
          env:
            - name: PIPELINE_RUN_ID
              valueFrom:
                fieldRef:
                  fieldPath: metadata.annotations['devops.cloud.ibm.com/tekton-pipeline']
        steps:
          - name: setup
            image: node:alpine
            script: |
              #!/bin/bash

              set -e -o pipefail

              if [ $PIPELINE_DEBUG == 1 ]; then
                pwd
                env
                trap env EXIT
                set -x
              fi

              export TOKEN=$(cat "/secrets/$(params.token)")

The line export TOKEN=$(cat "/secrets/$(params.token)") use a parameter token which was not added nor provided for the task, the linter is missing this.

mbwhite commented 8 months ago

Hi - yes it's a good idea; at present there's only 1 rule that checks inside the body of the scripts.

To any contributors out there.. please have a go! thanks