apiVersion: v1
items:
- apiVersion: tekton.dev/v1beta1
  kind: Task
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"tekton.dev/v1beta1","kind":"Task","metadata":{"annotations":{},"name":"buildah-suva","namespace":"col-ubi8-toolset-prod"},"spec":{"description":"Buildah task builds source into a container image and then pushes it to a container registry.\nBuildah Task builds source into a container image using Project Atomic's Buildah build tool.It uses Buildah's support for building from Dockerfiles, using its buildah bud command.This command executes the directives in the Dockerfile to assemble a container image, then pushes that image to a container registry.","params":[{"description":"Reference of the image buildah will produce.","name":"IMAGE","type":"string"},{"default":"registry.redhat.io/rhel8/buildah@sha256:6a68ece207bc5fd8db2dd5cc2d0b53136236fb5178eb5b71eebe5d07a3c33d13","description":"The location of the buildah builder image.","name":"BUILDER_IMAGE","type":"string"},{"default":"vfs","description":"Set buildah storage driver","name":"STORAGE_DRIVER","type":"string"},{"default":"./Dockerfile","description":"Path to the Dockerfile to build.","name":"DOCKERFILE","type":"string"},{"default":".","description":"Path to the directory to use as context.","name":"CONTEXT","type":"string"},{"default":"true","description":"Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)","name":"TLSVERIFY","type":"string"},{"default":"oci","description":"The format of the built container, oci or docker","name":"FORMAT","type":"string"},{"default":"","description":"Extra parameters passed for the build command when building images.","name":"BUILD_EXTRA_ARGS","type":"string"},{"default":"","description":"Extra parameters passed for the push command when pushing images.","name":"PUSH_EXTRA_ARGS","type":"string"}],"results":[{"description":"Digest of the image just built.","name":"IMAGE_DIGEST"}],"stepTemplate":{"name":"","resources":{"limits":{"cpu":"4","memory":"4Gi"},"requests":{"cpu":"2","memory":"2Gi"}}},"steps":[{"image":"$(params.BUILDER_IMAGE)","name":"build","resources":{"limits":{"cpu":"2","memory":"4Gi"},"requests":{"cpu":"2","memory":"2Gi"}},"script":"CERT_DIR_FLAG=\"--cert-dir $(workspaces.sslcertdir.path)\"\nbuildah ${CERT_DIR_FLAG} --storage-driver=$(params.STORAGE_DRIVER) bud \\\n  $(params.BUILD_EXTRA_ARGS) --format=$(params.FORMAT) \\\n  --tls-verify=$(params.TLSVERIFY) --no-cache \\\n  -f $(params.DOCKERFILE) -t $(params.IMAGE) $(params.CONTEXT)\n","volumeMounts":[{"mountPath":"/var/lib/containers","name":"varlibcontainers"}],"workingDir":"$(workspaces.source.path)"},{"image":"$(params.BUILDER_IMAGE)","name":"push","resources":{"limits":{"cpu":"2","memory":"4Gi"},"requests":{"cpu":"2","memory":"2Gi"}},"script":"CERT_DIR_FLAG=\"--cert-dir $(workspaces.sslcertdir.path)\"\nbuildah ${CERT_DIR_FLAG} --storage-driver=$(params.STORAGE_DRIVER) push \\\n  $(params.PUSH_EXTRA_ARGS) --tls-verify=$(params.TLSVERIFY) \\\n  --digestfile $(workspaces.source.path)/image-digest $(params.IMAGE) \\\n  docker://$(params.IMAGE)\n","volumeMounts":[{"mountPath":"/var/lib/containers","name":"varlibcontainers"}],"workingDir":"$(workspaces.source.path)"},{"image":"$(params.BUILDER_IMAGE)","name":"digest-to-results","resources":{"limits":{"cpu":"2","memory":"4Gi"},"requests":{"cpu":"2","memory":"2Gi"}},"script":"cat $(workspaces.source.path)/image-digest | tee /tekton/results/IMAGE_DIGEST"}],"volumes":[{"name":"varlibcontainers"}],"workspaces":[{"name":"source"},{"name":"sslcertdir"}]}}
    creationTimestamp: "2021-06-11T11:41:15Z"
    generation: 4
    managedFields:
    - apiVersion: tekton.dev/v1beta1
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:annotations:
            .: {}
            f:kubectl.kubernetes.io/last-applied-configuration: {}
        f:spec:
          .: {}
          f:description: {}
          f:params: {}
          f:results: {}
          f:stepTemplate:
            .: {}
            f:name: {}
            f:resources:
              .: {}
              f:limits:
                .: {}
                f:cpu: {}
                f:memory: {}
              f:requests:
                .: {}
                f:cpu: {}
                f:memory: {}
          f:steps: {}
          f:volumes: {}
          f:workspaces: {}
      manager: kubectl-client-side-apply
      operation: Update
      time: "2021-06-11T13:53:21Z"
    name: buildah-suva
    namespace: col-ubi8-toolset-prod
    resourceVersion: "399347747"
    selfLink: /apis/tekton.dev/v1beta1/namespaces/col-ubi8-toolset-prod/tasks/buildah-suva
    uid: 1058f65b-ecd4-4de0-8bc4-c2baf63ee46d
  spec:
    description: |-
      Buildah task builds source into a container image and then pushes it to a container registry.
      Buildah Task builds source into a container image using Project Atomic's Buildah build tool.It uses Buildah's support for building from Dockerfiles, using its buildah bud command.This command executes the directives in the Dockerfile to assemble a container image, then pushes that image to a container registry.
    params:
    - description: Reference of the image buildah will produce.
      name: IMAGE
      type: string
    - default: registry.redhat.io/rhel8/buildah@sha256:6a68ece207bc5fd8db2dd5cc2d0b53136236fb5178eb5b71eebe5d07a3c33d13
      description: The location of the buildah builder image.
      name: BUILDER_IMAGE
      type: string
    - default: vfs
      description: Set buildah storage driver
      name: STORAGE_DRIVER
      type: string
    - default: ./Dockerfile
      description: Path to the Dockerfile to build.
      name: DOCKERFILE
      type: string
    - default: .
      description: Path to the directory to use as context.
      name: CONTEXT
      type: string
    - default: "true"
      description: Verify the TLS on the registry endpoint (for push/pull to a non-TLS registry)
      name: TLSVERIFY
      type: string
    - default: oci
      description: The format of the built container, oci or docker
      name: FORMAT
      type: string
    - default: ""
      description: Extra parameters passed for the build command when building images.
      name: BUILD_EXTRA_ARGS
      type: string
    - default: ""
      description: Extra parameters passed for the push command when pushing images.
      name: PUSH_EXTRA_ARGS
      type: string
    results:
    - description: Digest of the image just built.
      name: IMAGE_DIGEST
    stepTemplate:
      name: ""
      resources:
        limits:
          cpu: "4"
          memory: 4Gi
        requests:
          cpu: "2"
          memory: 2Gi
    steps:
    - image: $(params.BUILDER_IMAGE)
      name: build
      resources:
        limits:
          cpu: "2"
          memory: 4Gi
        requests:
          cpu: "2"
          memory: 2Gi
      script: |
        CERT_DIR_FLAG="--cert-dir $(workspaces.sslcertdir.path)"
        buildah ${CERT_DIR_FLAG} --storage-driver=$(params.STORAGE_DRIVER) bud \
          $(params.BUILD_EXTRA_ARGS) --format=$(params.FORMAT) \
          --tls-verify=$(params.TLSVERIFY) --no-cache \
          -f $(params.DOCKERFILE) -t $(params.IMAGE) $(params.CONTEXT)
      volumeMounts:
      - mountPath: /var/lib/containers
        name: varlibcontainers
      workingDir: $(workspaces.source.path)
    - image: $(params.BUILDER_IMAGE)
      name: push
      resources:
        limits:
          cpu: "2"
          memory: 4Gi
        requests:
          cpu: "2"
          memory: 2Gi
      script: |
        CERT_DIR_FLAG="--cert-dir $(workspaces.sslcertdir.path)"
        buildah ${CERT_DIR_FLAG} --storage-driver=$(params.STORAGE_DRIVER) push \
          $(params.PUSH_EXTRA_ARGS) --tls-verify=$(params.TLSVERIFY) \
          --digestfile $(workspaces.source.path)/image-digest $(params.IMAGE) \
          docker://$(params.IMAGE)
      volumeMounts:
      - mountPath: /var/lib/containers
        name: varlibcontainers
      workingDir: $(workspaces.source.path)
    - image: $(params.BUILDER_IMAGE)
      name: digest-to-results
      resources:
        limits:
          cpu: "2"
          memory: 4Gi
        requests:
          cpu: "2"
          memory: 2Gi
      script: cat $(workspaces.source.path)/image-digest | tee /tekton/results/IMAGE_DIGEST
    volumes:
    - name: varlibcontainers
    workspaces:
    - name: source
    - name: sslcertdir
- apiVersion: tekton.dev/v1beta1
  kind: Task
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"tekton.dev/v1beta1","kind":"Task","metadata":{"annotations":{"tekton.dev/displayName":"git clone suva","tekton.dev/pipelines.minVersion":"0.21.0","tekton.dev/tags":"git"},"labels":{"app.kubernetes.io/version":"0.3"},"name":"git-clone-suva","namespace":"col-ubi8-toolset-prod"},"spec":{"description":"These Tasks are Git tasks to work with repositories used by other tasks in your Pipeline.\nThe git-clone Task will clone a repo from the provided url into the output Workspace. By default the repo will be cloned into the root of your Workspace. You can clone into a subdirectory by setting this Task's subdirectory param. This Task also supports sparse checkouts. To perform a sparse checkout, pass a list of comma separated directory patterns to this Task's sparseCheckoutDirectories param.","params":[{"description":"git url to clone","name":"url","type":"string"},{"default":"","description":"git revision to checkout (branch, tag, sha, ref…)","name":"revision","type":"string"},{"default":"","description":"(optional) git refspec to fetch before checking out revision","name":"refspec","type":"string"},{"default":"true","description":"defines if the resource should initialize and fetch the submodules","name":"submodules","type":"string"},{"default":"1","description":"performs a shallow clone where only the most recent commit(s) will be fetched","name":"depth","type":"string"},{"default":"true","description":"defines if http.sslVerify should be set to true or false in the global git config","name":"sslVerify","type":"string"},{"default":"","description":"subdirectory inside the \"output\" workspace to clone the git repo into","name":"subdirectory","type":"string"},{"default":"","description":"defines which directories patterns to match or exclude when performing a sparse checkout","name":"sparseCheckoutDirectories","type":"string"},{"default":"true","description":"clean out the contents of the repo's destination directory (if it already exists) before trying to clone the repo there","name":"deleteExisting","type":"string"},{"default":"","description":"git HTTP proxy server for non-SSL requests","name":"httpProxy","type":"string"},{"default":"","description":"git HTTPS proxy server for SSL requests","name":"httpsProxy","type":"string"},{"default":"","description":"git no proxy - opt out of proxying HTTP/HTTPS requests","name":"noProxy","type":"string"},{"default":"true","description":"log the commands used during execution","name":"verbose","type":"string"},{"default":"registry.redhat.io/openshift-pipelines/pipelines-git-init-rhel8@sha256:afc5d3f9efe26c7042635d43b8ffd09d67936e3d0b6b901dc08a33e20313d361","description":"the image used where the git-init binary is","name":"gitInitImage","type":"string"}],"results":[{"description":"The precise commit SHA that was fetched by this Task","name":"commit"},{"description":"The precise URL that was fetched by this Task","name":"url"}],"stepTemplate":{"name":"","resources":{"limits":{"cpu":"4","memory":"4Gi"},"requests":{"cpu":"2","memory":"2Gi"}}},"steps":[{"image":"$(params.gitInitImage)","name":"clone","resources":{"limits":{"cpu":"2","memory":"4Gi"},"requests":{"cpu":"2","memory":"2Gi"}},"script":"#!/bin/sh\nset -eu -o pipefail\n\nif [[ \"$(params.verbose)\" == \"true\" ]] ; then\n  set -x\nfi\n\nCHECKOUT_DIR=\"$(workspaces.output.path)/$(params.subdirectory)\"\n\ncleandir() {\n  # Delete any existing contents of the repo directory if it exists.\n  #\n  # We don't just \"rm -rf $CHECKOUT_DIR\" because $CHECKOUT_DIR might be \"/\"\n  # or the root of a mounted volume.\n  if [[ -d \"$CHECKOUT_DIR\" ]] ; then\n    # Delete non-hidden files and directories\n    rm -rf \"$CHECKOUT_DIR\"/* || true\n    # Delete files and directories starting with . but excluding ..\n    rm -rf \"$CHECKOUT_DIR\"/.[!.]* || true\n    # Delete files and directories starting with .. plus any other character\n    rm -rf \"$CHECKOUT_DIR\"/..?* || true\n  fi\n}\n\nif [[ \"$(params.deleteExisting)\" == \"true\" ]] ; then\n  cleandir\nfi\n\ntest -z \"$(params.httpProxy)\" || export HTTP_PROXY=$(params.httpProxy)\ntest -z \"$(params.httpsProxy)\" || export HTTPS_PROXY=$(params.httpsProxy)\ntest -z \"$(params.noProxy)\" || export NO_PROXY=$(params.noProxy)\n\n/ko-app/git-init \\\n  -url \"$(params.url)\" \\\n  -revision \"$(params.revision)\" \\\n  -refspec \"$(params.refspec)\" \\\n  -path \"$CHECKOUT_DIR\" \\\n  -sslVerify=\"$(params.sslVerify)\" \\\n  -submodules=\"$(params.submodules)\" \\\n  -depth \"$(params.depth)\" \\\n  -sparseCheckoutDirectories \"$(params.sparseCheckoutDirectories)\"\ncd \"$CHECKOUT_DIR\"\nRESULT_SHA=\"$(git rev-parse HEAD)\"\nEXIT_CODE=\"$?\"\nif [ \"$EXIT_CODE\" != 0 ] ; then\n  exit $EXIT_CODE\nfi\n# ensure we don't add a trailing newline to the result\necho -n \"$RESULT_SHA\" \u003e $(results.commit.path)\necho -n \"$(params.url)\" \u003e $(results.url.path)\n"}],"workspaces":[{"description":"The git repo will be cloned onto the volume backing this workspace","name":"output"}]}}
      tekton.dev/displayName: git clone suva
      tekton.dev/pipelines.minVersion: 0.21.0
      tekton.dev/tags: git
    creationTimestamp: "2021-06-11T09:53:19Z"
    generation: 3
    labels:
      app.kubernetes.io/version: "0.3"
    managedFields:
    - apiVersion: tekton.dev/v1beta1
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:annotations:
            .: {}
            f:kubectl.kubernetes.io/last-applied-configuration: {}
            f:tekton.dev/displayName: {}
            f:tekton.dev/pipelines.minVersion: {}
            f:tekton.dev/tags: {}
          f:labels:
            .: {}
            f:app.kubernetes.io/version: {}
        f:spec:
          .: {}
          f:description: {}
          f:params: {}
          f:results: {}
          f:stepTemplate:
            .: {}
            f:name: {}
            f:resources:
              .: {}
              f:limits:
                .: {}
                f:cpu: {}
                f:memory: {}
              f:requests:
                .: {}
                f:cpu: {}
                f:memory: {}
          f:steps: {}
          f:workspaces: {}
      manager: kubectl-client-side-apply
      operation: Update
      time: "2021-06-11T09:53:19Z"
    name: git-clone-suva
    namespace: col-ubi8-toolset-prod
    resourceVersion: "390569982"
    selfLink: /apis/tekton.dev/v1beta1/namespaces/col-ubi8-toolset-prod/tasks/git-clone-suva
    uid: 54fe5010-0271-4c66-9d7d-fabd7e6a9c15
  spec:
    description: |-
      These Tasks are Git tasks to work with repositories used by other tasks in your Pipeline.
      The git-clone Task will clone a repo from the provided url into the output Workspace. By default the repo will be cloned into the root of your Workspace. You can clone into a subdirectory by setting this Task's subdirectory param. This Task also supports sparse checkouts. To perform a sparse checkout, pass a list of comma separated directory patterns to this Task's sparseCheckoutDirectories param.
    params:
    - description: git url to clone
      name: url
      type: string
    - default: ""
      description: git revision to checkout (branch, tag, sha, ref…)
      name: revision
      type: string
    - default: ""
      description: (optional) git refspec to fetch before checking out revision
      name: refspec
      type: string
    - default: "true"
      description: defines if the resource should initialize and fetch the submodules
      name: submodules
      type: string
    - default: "1"
      description: performs a shallow clone where only the most recent commit(s) will be fetched
      name: depth
      type: string
    - default: "true"
      description: defines if http.sslVerify should be set to true or false in the global git config
      name: sslVerify
      type: string
    - default: ""
      description: subdirectory inside the "output" workspace to clone the git repo into
      name: subdirectory
      type: string
    - default: ""
      description: defines which directories patterns to match or exclude when performing a sparse checkout
      name: sparseCheckoutDirectories
      type: string
    - default: "true"
      description: clean out the contents of the repo's destination directory (if it already exists) before trying to clone the repo there
      name: deleteExisting
      type: string
    - default: ""
      description: git HTTP proxy server for non-SSL requests
      name: httpProxy
      type: string
    - default: ""
      description: git HTTPS proxy server for SSL requests
      name: httpsProxy
      type: string
    - default: ""
      description: git no proxy - opt out of proxying HTTP/HTTPS requests
      name: noProxy
      type: string
    - default: "true"
      description: log the commands used during execution
      name: verbose
      type: string
    - default: registry.redhat.io/openshift-pipelines/pipelines-git-init-rhel8@sha256:afc5d3f9efe26c7042635d43b8ffd09d67936e3d0b6b901dc08a33e20313d361
      description: the image used where the git-init binary is
      name: gitInitImage
      type: string
    results:
    - description: The precise commit SHA that was fetched by this Task
      name: commit
    - description: The precise URL that was fetched by this Task
      name: url
    stepTemplate:
      name: ""
      resources:
        limits:
          cpu: "4"
          memory: 4Gi
        requests:
          cpu: "2"
          memory: 2Gi
    steps:
    - image: $(params.gitInitImage)
      name: clone
      resources:
        limits:
          cpu: "2"
          memory: 4Gi
        requests:
          cpu: "2"
          memory: 2Gi
      script: |
        #!/bin/sh
        set -eu -o pipefail

        if [[ "$(params.verbose)" == "true" ]] ; then
          set -x
        fi

        CHECKOUT_DIR="$(workspaces.output.path)/$(params.subdirectory)"

        cleandir() {
          # Delete any existing contents of the repo directory if it exists.
          #
          # We don't just "rm -rf $CHECKOUT_DIR" because $CHECKOUT_DIR might be "/"
          # or the root of a mounted volume.
          if [[ -d "$CHECKOUT_DIR" ]] ; then
            # Delete non-hidden files and directories
            rm -rf "$CHECKOUT_DIR"/* || true
            # Delete files and directories starting with . but excluding ..
            rm -rf "$CHECKOUT_DIR"/.[!.]* || true
            # Delete files and directories starting with .. plus any other character
            rm -rf "$CHECKOUT_DIR"/..?* || true
          fi
        }

        if [[ "$(params.deleteExisting)" == "true" ]] ; then
          cleandir
        fi

        test -z "$(params.httpProxy)" || export HTTP_PROXY=$(params.httpProxy)
        test -z "$(params.httpsProxy)" || export HTTPS_PROXY=$(params.httpsProxy)
        test -z "$(params.noProxy)" || export NO_PROXY=$(params.noProxy)

        /ko-app/git-init \
          -url "$(params.url)" \
          -revision "$(params.revision)" \
          -refspec "$(params.refspec)" \
          -path "$CHECKOUT_DIR" \
          -sslVerify="$(params.sslVerify)" \
          -submodules="$(params.submodules)" \
          -depth "$(params.depth)" \
          -sparseCheckoutDirectories "$(params.sparseCheckoutDirectories)"
        cd "$CHECKOUT_DIR"
        RESULT_SHA="$(git rev-parse HEAD)"
        EXIT_CODE="$?"
        if [ "$EXIT_CODE" != 0 ] ; then
          exit $EXIT_CODE
        fi
        # ensure we don't add a trailing newline to the result
        echo -n "$RESULT_SHA" > $(results.commit.path)
        echo -n "$(params.url)" > $(results.url.path)
    workspaces:
    - description: The git repo will be cloned onto the volume backing this workspace
      name: output
- apiVersion: tekton.dev/v1beta1
  kind: Task
  metadata:
    annotations:
      kubectl.kubernetes.io/last-applied-configuration: |
        {"apiVersion":"tekton.dev/v1beta1","kind":"Task","metadata":{"annotations":{"tekton.dev/displayName":"pvc-cleanup","tekton.dev/tags":"pvc-cleanup"},"labels":{"app.kubernetes.io/version":"0.1"},"name":"pvc-cleanup-suva","namespace":"col-ubi8-toolset-prod"},"spec":{"description":"This task can be used to cleanup used pvc claims from pipelineruns","params":[{"default":"harbor.suvanet.ch/columbo-intern/col-ubi8-toolset:latest","description":"The base image for the task.\n","name":"BASE_IMAGE","type":"string"},{"default":"10","description":"Keeping only the xx most recent pipelines","name":"MAX_PIPELINES","type":"string"},{"default":"10","description":"Keeping only the pipelines newer than xx days","name":"RETENTION_DAYS","type":"string"}],"stepTemplate":{"name":"","resources":{"limits":{"cpu":"4","memory":"4Gi"},"requests":{"cpu":"2","memory":"2Gi"}}},"steps":[{"image":"$(params.BASE_IMAGE)","name":"max-pipeline","resources":{"limits":{"cpu":"2","memory":"4Gi"},"requests":{"cpu":"2","memory":"2Gi"}},"script":"if [[ $(params.MAX_PIPELINES) != '0' ]]\nthen\n  tkn pipelinerun list\n  tkn pipelinerun delete --keep $(params.MAX_PIPELINES) -f\nfi\n"},{"image":"$(params.BASE_IMAGE)","name":"retention-days","resources":{"limits":{"cpu":"2","memory":"4Gi"},"requests":{"cpu":"2","memory":"2Gi"}},"script":"#!/usr/bin/env bash\nif [[ $(params.RETENTION_DAYS) != '0' ]]    \nthen \n  retention_days=$(params.RETENTION_DAYS)\n\n  oc get pipelinerun | while read pipeline_name pipeline_status\n  pipeline_reason pipeline_start pipeline_completion; do\n\n  age_in_days=$(echo $pipeline_completion | grep -oE \"[0-9]+d\" | tr -d\n  'd')\n\n  if [[ $age_in_days -gt $retention_days ]];then\n      echo \"Deleting pipelinerun ${pipeline_name} because ${age_in_days} \u003e ${retention_days}\"\n      tkn pipelinerun delete \"${pipeline_name}\"\n  fi\n\n  done \n\nfi\n"}]}}
      tekton.dev/displayName: pvc-cleanup
      tekton.dev/tags: pvc-cleanup
    creationTimestamp: "2021-06-11T11:41:15Z"
    generation: 1
    labels:
      app.kubernetes.io/version: "0.1"
    managedFields:
    - apiVersion: tekton.dev/v1beta1
      fieldsType: FieldsV1
      fieldsV1:
        f:metadata:
          f:annotations:
            .: {}
            f:kubectl.kubernetes.io/last-applied-configuration: {}
            f:tekton.dev/displayName: {}
            f:tekton.dev/tags: {}
          f:labels:
            .: {}
            f:app.kubernetes.io/version: {}
        f:spec:
          .: {}
          f:description: {}
          f:params: {}
          f:stepTemplate:
            .: {}
            f:name: {}
            f:resources:
              .: {}
              f:limits:
                .: {}
                f:cpu: {}
                f:memory: {}
              f:requests:
                .: {}
                f:cpu: {}
                f:memory: {}
          f:steps: {}
      manager: kubectl-client-side-apply
      operation: Update
      time: "2021-06-11T11:41:15Z"
    name: pvc-cleanup-suva
    namespace: col-ubi8-toolset-prod
    resourceVersion: "390364752"
    selfLink: /apis/tekton.dev/v1beta1/namespaces/col-ubi8-toolset-prod/tasks/pvc-cleanup-suva
    uid: 221c824b-035e-404c-a275-72cf25c0f877
  spec:
    description: This task can be used to cleanup used pvc claims from pipelineruns
    params:
    - default: harbor.suvanet.ch/columbo-intern/col-ubi8-toolset:latest
      description: |
        The base image for the task.
      name: BASE_IMAGE
      type: string
    - default: "10"
      description: Keeping only the xx most recent pipelines
      name: MAX_PIPELINES
      type: string
    - default: "10"
      description: Keeping only the pipelines newer than xx days
      name: RETENTION_DAYS
      type: string
    stepTemplate:
      name: ""
      resources:
        limits:
          cpu: "4"
          memory: 4Gi
        requests:
          cpu: "2"
          memory: 2Gi
    steps:
    - image: $(params.BASE_IMAGE)
      name: max-pipeline
      resources:
        limits:
          cpu: "2"
          memory: 4Gi
        requests:
          cpu: "2"
          memory: 2Gi
      script: |
        if [[ $(params.MAX_PIPELINES) != '0' ]]
        then
          tkn pipelinerun list
          tkn pipelinerun delete --keep $(params.MAX_PIPELINES) -f
        fi
    - image: $(params.BASE_IMAGE)
      name: retention-days
      resources:
        limits:
          cpu: "2"
          memory: 4Gi
        requests:
          cpu: "2"
          memory: 2Gi
      script: "#!/usr/bin/env bash\nif [[ $(params.RETENTION_DAYS) != '0' ]]    \nthen \n  retention_days=$(params.RETENTION_DAYS)\n\n  oc get pipelinerun | while read pipeline_name pipeline_status\n  pipeline_reason pipeline_start pipeline_completion; do\n\n  age_in_days=$(echo $pipeline_completion | grep -oE \"[0-9]+d\" | tr -d\n  'd')\n\n  if [[ $age_in_days -gt $retention_days ]];then\n      echo \"Deleting pipelinerun ${pipeline_name} because ${age_in_days} > ${retention_days}\"\n      tkn pipelinerun delete \"${pipeline_name}\"\n  fi\n\n  done \n\nfi\n"
kind: List
metadata:
  resourceVersion: ""
  selfLink: ""
