# This example TaskRun demonstrates sharing files between a Step
# and Sidecar via a Workspace.
#
# The Step writes a file to the Workspace and then waits for the Sidecar
# to respond. The Sidecar sees the Step's file and writes its response.
# The Step sees the response and exits.
kind: TaskRun
apiVersion: tekton.dev/v1beta1
metadata:
  generateName: workspace-in-sidecar-
spec:
  timeout: 60s
  workspaces:
  - name: signals
    emptyDir: {}
  taskSpec:
    workspaces:
    - name: signals
    steps:
    - image: alpine:3.12.0
      script: |
        #!/usr/bin/env ash
        echo "foo" > "$(workspaces.signals.path)"/bar
        echo "Wrote bar file"
        while [ ! -f "$(workspaces.signals.path)"/ready ] ; do
          echo "Waiting for $(workspaces.signals.path)/ready"
          sleep 1
        done
        echo "Saw ready file"
    sidecars:
    - image: alpine:3.12.0
      script: |
        #!/usr/bin/env ash
        while [ ! -f "$(workspaces.signals.path)"/bar ] ; do
          echo "Waiting for $(workspaces.signals.path)/bar"
          sleep 1
        done
        touch "$(workspaces.signals.path)"/ready
        echo "Wrote ready file"
