apiVersion: v1
kind: ConfigMap
metadata:
  name: "@(Model.Name)"
  namespace: "@(Model.NameSpace)"
data:
  prepare: |
    bash /kqi/scripts/common/show-logo
    bash /kqi/scripts/common/prepare-kqi-conf
    bash /kqi/scripts/common/prepare-git
    
    echo "------------------------- [KAMONOHASHI Main] deploy data into /kqi/input/$DATA_ID . -------------------------"
    mkdir -p /kqi/input/$DATA_ID
    kqi data download-files -d /kqi/input/$DATA_ID $DATA_ID
    kqi data get -d /kqi/input/meta.json $DATA_ID
  main: |
    bash /kqi/scripts/common/wait-ready
    cd /kqi/git
    echo "------------------------- [KAMONOHASHI Main] start main command -------------------------"
    @Raw(Model.EntryPoint)
    bash /kqi/scripts/common/notify-finish $?
  finish: |
    bash /kqi/scripts/common/prepare-kqi-conf
    bash /kqi/scripts/common/wait-finish
      
    if [ $(cat /kqi/tmp/result_exit_code) -eq 0 ]
    then
      echo "------------------------- [KAMONOHASHI Finish] retrun code is 0. complete  -------------------------"
      kqi preprocessing build-history-files -did $DATA_ID -s /kqi/output $TAGS $PREPROCESSING_ID
    else
      echo "------------------------- [KAMONOHASHI Finish] retrun code is $RESULT. kill  -------------------------"
      kqi preprocessing halt-history -did $DATA_ID $PREPROCESSING_ID
    fi
    