apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
  name: skaffold-image-leeroy-web-1
spec:
  type: image
  params:
  - name: url
    value: gcr.io/dlorenc-vmtest2/leeroy-web  # Replace this URL with $KO_DOCKER_REPO
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
  name: skaffold-image-leeroy-web-2
spec:
  type: image
  params:
  - name: url
    value: gcr.io/christiewilson-catfactory/leeroy-web  # Replace this URL with $KO_DOCKER_REPO
---
# This demo modifies the cluster (deploys to it) you must use a service
# account with permission to admin the cluster (or make your default user an admin
# of the `default` namespace with default-cluster-admin).
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  generateName: default-cluster-admin-
subjects:
  - kind: ServiceAccount
    name: default
    namespace: default
roleRef:
  kind: ClusterRole
  name: cluster-admin
  apiGroup: rbac.authorization.k8s.io
---
apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
  name: skaffold-git-multiple-output-image
spec:
  type: git
  params:
  - name: revision
    value: v0.32.0
  - name: url
    value: https://github.com/GoogleContainerTools/skaffold
---
# This task is currently hardcoding a index.json file instead of
# building an image since kaniko and other easy to use tools don't
# support exporting this file yet
apiVersion: tekton.dev/v1alpha1
kind: Task
metadata:
  name: multiple-build-push-kaniko
spec:
  inputs:
    resources:
    - name: sourcerepo
      type: git
  outputs:
    resources:
    - name: builtImage1
      type: image
    - name: builtImage2
      type: image
  steps:
  - name: build-and-push-1
    image: busybox
    script: |
      set -ex
      mkdir -p /tekton/home/image-outputs/builtImage1
      cat <<EOF > /tekton/home/image-outputs/builtImage1/index.json
      {
        "schemaVersion": 2,
        "manifests": [
          {
            "mediaType": "application/vnd.oci.image.index.v1+json",
            "size": 314,
            "digest": "sha256:05f95b26ed10668b7183c1e2da98610e91372fa9f510046d4ce5812addad86b5"
          }
        ]
      }
  - name: build-and-push-2
    image: busybox
    script: |
      set -e
      mkdir -p /tekton/home/image-outputs/builtImage2
      cat <<EOF > /tekton/home/image-outputs/builtImage2/index.json
      {
        "schemaVersion": 2,
        "manifests": [
          {
            "mediaType": "application/vnd.oci.image.index.v1+json",
            "size": 314,
            "digest": "sha256:05f95b26ed10668b7183c1e2da98610e91372fa9f510046d4ce5812addad86b5"
          }
        ]
      }
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
  name: multiple-build-push-kaniko-run
spec:
  taskRef:
    name: multiple-build-push-kaniko
  inputs:
    resources:
    - name: sourcerepo
      resourceRef:
        name: skaffold-git-multiple-output-image
  outputs:
    resources:
    - name: builtImage1
      resourceRef:
        name: skaffold-image-leeroy-web-1
    - name: builtImage2
      resourceRef:
        name: skaffold-image-leeroy-web-2
