---
pipeline:
  name: daily_path_structure
transform:
  image: registry.access.redhat.com/ubi8/ubi-minimal:8.3
  cmd: ["/bin/bash"]
  stdin:
  - "#!/bin/bash"
  - "# If END_DATE unset, set to yesterday"
  - "[  -z $END_DATE ] && END_DATE=$(date -u -d '1 day ago' +%Y/%m/%d)"
  - "# Create daily folder structure from start date to end date"
  - "for d in $(seq $(date -u +%s -d $START_DATE) +86400 $(date -u +%s -d $END_DATE)) ; do"
  - "date_path=$(date -u +%Y/%m/%d -d @$d)"
  - "echo $OUT_PATH/$date_path"
  - "touch $OUT_PATH/$date_path/empty"
  - "mkdir -p $OUT_PATH/$date_path"
  - "done"
  env:
    # START_DATE and END_DATE indicate the date range (inclusive) to create the /Y/M/D folder structure
    # START_DATE must be set, format "YYYY-MM-DD"
    # END_DATE can be set or unset (remove line entirely to unset). If unset, end date will be yesterday. 
    OUT_PATH: /pfs/out
    START_DATE: "2020-01-01"
    END_DATE: "2020-01-06"
input:
  cron:
    name: tick
    spec: "@daily"
    overwrite: true
enable_stats: false
standby: true
