apiVersion: tekton.dev/v1alpha1
kind: PipelineResource
metadata:
  name: skaffold-image-leeroy-web-output-image
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-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: build-push-kaniko-output-image
spec:
  inputs:
    resources:
    - name: sourcerepo
      type: git
  outputs:
    resources:
    - name: builtImage
      type: image
      targetPath: /workspace/sourcerepo
  steps:
  - name: build-and-push
    image: busybox
    script: |
      set -e
      cat <<EOF > $(inputs.resources.sourcerepo.path)/index.json
      {
        "schemaVersion": 2,
        "manifests": [
          {
            "mediaType": "application/vnd.oci.image.index.v1+json",
            "size": 314,
            "digest": "sha256:05f95b26ed10668b7183c1e2da98610e91372fa9f510046d4ce5812addad86b5"
          }
        ]
      }
  - name: echo
    image: busybox
    script: cat $(inputs.resources.sourcerepo.path)/index.json
---
apiVersion: tekton.dev/v1alpha1
kind: TaskRun
metadata:
  name: build-push-run-output-image
spec:
  taskRef:
    name: build-push-kaniko-output-image
  inputs:
    resources:
    - name: sourcerepo
      resourceRef:
        name: skaffold-git-output-image
  outputs:
    resources:
    - name: builtImage
      resourceRef:
        name: skaffold-image-leeroy-web-output-image
