{{ if .Values.pipelines.deployableResources.tasks }}
apiVersion: tekton.dev/v1
kind: Task
metadata:
  name: run-quality-gate
spec:
  description: >-
    This task runs a quality gate. It can use a Kubeconfig secret to connect to a remote Kubernetes cluster.
  volumes:
    - name: kubeconfig
      secret:
        secretName: $(params.KUBECONFIG_SECRET_NAME)
        optional: true
  params:
    - description: >
        EDP kind:CDPipeline name used for deployment. For example: mypipe,
        myfeature
      name: PIPELINE
      type: string
    - description: >
        EDP kind:Stage name of the kind:CDPipeline defined in the CDPIPELINE
        values. For example: dev, test, prod
      name: STAGE
      type: string
    - name: BASE_IMAGE
      description: The base image for the task (different for buildtools).
      type: string
      default: ""
    - name: EXTRA_COMMANDS
      type: string
      description: Extra commands
      default: ""
    - name: KUBECONFIG_SECRET_NAME
      type: string
      description: The name of secret with Kubeconfig to connect to the remote cluster
      default: "in-cluster"
  steps:
    - name: run
      image: $(params.BASE_IMAGE)
      volumeMounts:
        - name: kubeconfig
          mountPath: /workspace/source/kube
      envFrom:
        - configMapRef:
            name: $(params.PIPELINE)-$(params.STAGE)
      script: |
        set -ex
        export KUBECONFIG="workspace/source/kube/config"
        $(params.EXTRA_COMMANDS)
{{ end }}
