# auto generated by script/update-tasks.sh
# DO NOT EDIT: use the script instead
# source: https://raw.githubusercontent.com/openshift/tektoncd-catalog/release-v0.28/task/skopeo-copy/0.1/skopeo-copy.yaml
#
---
apiVersion: tekton.dev/v1beta1
kind: ClusterTask
metadata:
  name: skopeo-copy-1-6-0
  labels:
    app.kubernetes.io/version: "0.1"
  annotations:
    tekton.dev/pipelines.minVersion: "0.12.1"
    tekton.dev/categories: CLI
    tekton.dev/tags: cli
    tekton.dev/displayName: "skopeo copy"
    tekton.dev/platforms: "linux/amd64,linux/s390x,linux/ppc64le,linux/arm64"
spec:
  description: >-
    Skopeo is a command line tool for working with remote image registries.

    Skopeo doesn’t require a daemon to be running while performing its operations.
    In particular, the handy skopeo command called copy will ease the whole image
    copy operation. The copy command will take care of copying the image from
    internal.registry to production.registry. If your production registry requires
    credentials to login in order to push the image, skopeo can handle that as well.

  workspaces:
    - name: images-url
  params:
    - name: srcImageURL
      description: URL of the image to be copied to the destination registry
      type: string
      default: ""
    - name: destImageURL
      description: URL of the image where the image from source should be copied to
      type: string
      default: ""
    - name: srcTLSverify
      description: Verify the TLS on the src registry endpoint
      type: string
      default: "true"
    - name: destTLSverify
      description: Verify the TLS on the dest registry endpoint
      type: string
      default: "true"
  steps:
    - name: skopeo-copy
      image: registry.redhat.io/rhel8/skopeo@sha256:7297e3b42ef1d56a5bc1d64a979d05c157bf31b476cc526386c873a89459610a
      script: |
        # Function to copy multiple images.
        #
        copyimages() {
          filename='$(workspaces.images-url.path)/url.txt'
          while IFS= read line || [ -n "$line" ]
          do
            cmd=""
            for url in $line
            do
              # echo $url
              cmd="$cmd \
                  $url"
            done
            skopeo copy $cmd --src-tls-verify=$(params.srcTLSverify) --dest-tls-verify=$(params.destTLSverify)
            echo $cmd
          done < "$filename"
        }
        #
        # If single image is to be copied then, it can be passed through
        # params in the taskrun.
        if [ "$(params.srcImageURL)" != "" ] && [ "$(params.destImageURL)" != "" ] ; then
          skopeo copy "$(params.srcImageURL)" "$(params.destImageURL)" --src-tls-verify=$(params.srcTLSverify) --dest-tls-verify=$(params.destTLSverify)
        else
          # If file is provided as a configmap in the workspace then multiple images can be copied.
          #
          copyimages
        fi
