apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: my-pvc
spec:
  resources:
    requests:
      storage: 5Gi
  volumeMode: Filesystem
  accessModes:
    - ReadWriteOnce
---
apiVersion: v1
kind: ConfigMap
metadata:
  name: my-configmap
data:
  message: hello world
---
apiVersion: v1
kind: Secret
metadata:
  name: my-secret
type: Opaque
stringData:
  username: user
data:
  message: aGVsbG8gc2VjcmV0
---
apiVersion: tekton.dev/v1
kind: TaskRun
metadata:
  generateName: custom-volume-
spec:
  params:
    - name: name
      value: "my"
    - name: path
      value: "testing"
  workspaces:
    - name: custom
      persistentVolumeClaim:
        claimName: $(params.name)-pvc
      subPath: $(params.name)-subdir
    - name: custom2
      persistentVolumeClaim:
        claimName: $(params.name)-pvc
    - name: custom3
      emptyDir: {}
      subPath: $(params.path)
    - name: custom4
      configMap:
        name: $(params.name)-configmap
        items:
          - key: message
            path: my-message.txt
    - name: custom5
      secret:
        secretName: $(params.name)-secret
  taskSpec:
    steps:
      - name: write
        image: ubuntu
        script: echo $(workspaces.custom.volume) > $(workspaces.custom.path)/foo
      - name: read
        image: ubuntu
        script: cat $(workspaces.custom.path)/foo | grep $(workspaces.custom.volume)
      - name: write2
        image: ubuntu
        script: echo $(workspaces.custom2.path) > $(workspaces.custom2.path)/foo
      - name: read2
        image: ubuntu
        script: cat $(workspaces.custom2.path)/foo | grep $(workspaces.custom2.path)
      - name: write3
        image: ubuntu
        script: echo $(workspaces.custom3.path) > $(workspaces.custom3.path)/foo
      - name: read3
        image: ubuntu
        script: cat $(workspaces.custom3.path)/foo | grep $(workspaces.custom3.path)
      - name: readconfigmap
        image: ubuntu
        script: cat $(workspaces.custom4.path)/$(params.name)-message.txt | grep "hello world"
      - name: readsecret
        image: ubuntu
        script: |
          #!/usr/bin/env bash
          set -xe
          cat $(workspaces.custom5.path)/username | grep "user"
          cat $(workspaces.custom5.path)/message | grep "hello secret"
    workspaces:
      - name: custom
      - name: custom2
        mountPath: /foo/bar/baz
      - name: custom3
      - name: custom4
        mountPath: /baz/bar/quux
      - name: custom5
        mountPath: /my/secret/volume