# auto generated by script/update-tasks.sh
# DO NOT EDIT: use the script instead
# source: https://raw.githubusercontent.com/openshift/tektoncd-catalog/release-v0.24/task/openshift-client/0.2/openshift-client.yaml
#
---
---
apiVersion: tekton.dev/v1beta1
kind: ClusterTask
metadata:
  name: openshift-client-1-5-0
  labels:
    app.kubernetes.io/version: "0.2"
  annotations:
    tekton.dev/pipelines.minVersion: "0.17.0"
    tekton.dev/tags: cli
    tekton.dev/displayName: "openshift client"
spec:
  workspaces:
    - name: manifest-dir
      optional: true
      description: >-
        The workspace which contains kubernetes manifests which we want to apply on the cluster.
    - name: kubeconfig-dir
      optional: true
      description: >-
        The workspace which contains the the kubeconfig file if in case we want to run the oc command on another cluster.
  description: >-
    This task runs commands against the cluster provided by user
    and if not provided then where the Task is being executed.

    OpenShift is a Kubernetes distribution from Red Hat which provides oc,
    the OpenShift CLI that complements kubectl for simplifying deployment
    and configuration applications on OpenShift.

  params:
    - name: SCRIPT
      description: The OpenShift CLI arguments to run
      type: string
      default: "oc help"
    - name: VERSION
      description: The OpenShift Version to use
      type: string
      default: "latest"
  steps:
    - name: oc
      image: image-registry.openshift-image-registry.svc:5000/openshift/cli:$(params.VERSION)
      script: |
        #!/usr/bin/env bash

        [[ "$(workspaces.manifest-dir.bound)" == "true" ]] && \
        cd $(workspaces.manifest-dir.path)

        [[ "$(workspaces.kubeconfig-dir.bound)" == "true" ]] && \
        [[ -f $(workspaces.kubeconfig-dir.path)/kubeconfig ]] && \
        export KUBECONFIG=$(workspaces.kubeconfig-dir.path)/kubeconfig

        $(params.SCRIPT)
