apiVersion: tekton.dev/v1
kind: Task
metadata:
  annotations:
    artifacthub.io/category: integration-delivery
    artifacthub.io/maintainers: |
      - name: OpenShift Pipeline task maintainers
        email: pipelines-extcomm@redhat.com
    artifacthub.io/provider: Red Hat
    artifacthub.io/recommendations: |
      - url: https://tekton.dev/
    operator.tekton.dev/last-applied-hash: 394c680b7a7b11d3c183424916629266151973679e721c0d753a79c5a961ac3a
    tekton.dev/displayName: CLI
    tekton.dev/pipelines.minVersion: 0.17.0
    tekton.dev/source: https://github.com/openshift-pipelines/task-openshift
    tekton.dev/tags: cli
  creationTimestamp: "2024-06-10T13:45:47Z"
  generation: 1
  labels:
    app.kubernetes.io/version: 0.1.0
    operator.tekton.dev/operand-name: openshift-pipelines-addons
    operator.tekton.dev/provider-type: redhat
  name: openshift-client
  namespace: openshift-pipelines
  ownerReferences:
  - apiVersion: operator.tekton.dev/v1alpha1
    blockOwnerDeletion: true
    controller: true
    kind: TektonInstallerSet
    name: addon-custom-resolvertask-4w7k4
    uid: 44cc2eb3-48d8-4e6c-82ef-203759a9a88b
  resourceVersion: "38845"
  uid: 46513a9b-1b74-42f9-a020-d0671e49c3a2
spec:
  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:
  - default: oc help
    description: The OpenShift CLI arguments to run
    name: SCRIPT
    type: string
  - default: latest
    description: The OpenShift Version to use
    name: VERSION
    type: string
  stepTemplate:
    computeResources: {}
    env:
    - name: PARAMS_SCRIPT
      value: $(params.SCRIPT)
    - name: PARAMS_VERSION
      value: $(params.VERSION)
    - name: WORKSPACES_MANIFEST_DIR_BOUND
      value: $(workspaces.manifest_dir.bound)
    - name: WORKSPACES_MANIFEST_DIR_PATH
      value: $(workspaces.manifest_dir.path)
    - name: WORKSPACES_KUBECONFIG_DIR_BOUND
      value: $(workspaces.kubeconfig_dir.bound)
    - name: WORKSPACES_KUBECONFIG_DIR_PATH
      value: $(workspaces.kubeconfig_dir.path)
  steps:
  - computeResources: {}
    image: registry.access.redhat.com/ubi8-minimal:latest
    name: load-scripts
    script: |
      set -e
      printf '%s' "IyEvdXNyL2Jpbi9lbnYgYmFzaAoKIyB0ZWt0b24ncyBob21lIGRpcmVjdG9yeQpkZWNsYXJlIC1yeCBURUtUT05fSE9NRT0iJHtURUtUT05fSE9NRTotL3Rla3Rvbi9ob21lfSIKCiMKIyBGdW5jdGlvbnMKIwoKZnVuY3Rpb24gZmFpbCgpIHsKICAgIGVjaG8gIkVSUk9SOiAkeyp9IiAyPiYxCiAgICBleGl0IDEKfQoKZnVuY3Rpb24gcGhhc2UoKSB7CiAgICBlY2hvICItLS0+IFBoYXNlOiAkeyp9Li4uIgp9CgojIGFzc2VydCBsb2NhbCB2YXJpYWJsZXMgYXJlIGV4cG9yZXRlZCBvbiB0aGUgZW52aXJvbm1lbnQKZnVuY3Rpb24gZXhwb3J0ZWRfb3JfZmFpbCgpIHsKICAgIGRlY2xhcmUgLWEgX3JlcXVpcmVkX3ZhcnM9IiR7QH0iCgogICAgZm9yIHYgaW4gJHtfcmVxdWlyZWRfdmFyc1tAXX07IGRvCiAgICAgICAgW1sgLXogIiR7IXZ9IiBdXSAmJgogICAgICAgICAgICBmYWlsICInJHt2fScgZW52aXJvbm1lbnQgdmFyaWFibGUgaXMgbm90IHNldCEiCiAgICBkb25lCgogICAgcmV0dXJuIDAKfQoK" |base64 -d >common.sh
      printf '%s' "IyEvdXNyL2Jpbi9lbnYgYmFzaAoKc2hvcHQgLXMgaW5oZXJpdF9lcnJleGl0CnNldCAtZXUgLW8gcGlwZWZhaWwKCnNvdXJjZSAiJChkaXJuYW1lICR7QkFTSF9TT1VSQ0VbMF19KS9jb21tb24uc2giCnNvdXJjZSAiJChkaXJuYW1lICR7QkFTSF9TT1VSQ0VbMF19KS9vYy1jb21tb24uc2giCgpbWyAiJHtXT1JLU1BBQ0VTX01BTklGRVNUX0RJ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JfQk9VTkQgXAogICAgV09SS1NQQUNFU19LVUJFQ09ORklHX0RJUl9CT1VORCBcCiAgICBQQVJBTVNfU0NSSVBUIFwKICAgIFBBUkFNU19WRVJTSU9OCg==" |base64 -d >oc-common.sh
      chmod +x oc-*.sh
    volumeMounts:
    - mountPath: /scripts
      name: scripts-dir
    workingDir: /scripts
  - command:
    - /scripts/oc-client.sh
    computeResources: {}
    env:
    - name: HOME
      value: /tekton/home
    image: registry.redhat.io/openshift4/ose-cli@sha256:3d5b31cc3fbf878015e5c3ed1d48379d74b15b77a1a823024a7a2b7cd5e2e86d
    name: oc
    securityContext:
      runAsNonRoot: true
      runAsUser: 65532
    volumeMounts:
    - mountPath: /scripts
      name: scripts-dir
  volumes:
  - emptyDir: {}
    name: scripts-dir
  workspaces:
  - description: The workspace which contains kubernetes manifests which we want to
      apply on the cluster.
    name: manifest_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.
    name: kubeconfig_dir
    optional: true
