Olaf Bohlen
2023-01-02 b6d772f47ffa47249a445f199b88c3f324eadd76
receipt-processor.ksh
@@ -56,6 +56,7 @@
    # now that we have a list of updated receipts, we are going to process them
    for r in ${updatedreceipts}; do
   printf "\n\nNew receipt found: %s\n" "${receiptname[${r}]}"
   # get the name for the UID and fetch only that object
   receipt=$(eval curl -XGET ${CURLOPTS} '${APIURL}/apis/de.eenfach.olbohlen/v1/namespaces/${NAMESPACE}/cookiereceipts/${receiptname[${r}]}' )
@@ -70,13 +71,14 @@
   
   preheat_b=$( echo "${receipt}" | jq -r .spec.preheat )
   if [ "x${preheat_b}" == "xtrue" ]; then
       printf "Pre: we heat up the oven to %s degrees %s\n" "${temperature}" "${scale:-Celsius}"
       printf "Pre: we heat up the oven to %s degrees %s\n\n" "${temperature}" "${scale:-Celsius}"
   fi
   # how many ingredients do we have?
   num_in=$(echo "${receipt}" | jq .spec.ingredients\[\].name | wc -l)
   # list up that we fetch needed ingredients
   printf "Fetching ingredients from receipt:\n"
   i=0
   while [ ${i} -lt ${num_in} ]; do
       in_name=$( echo "${receipt}" | jq -r .spec.ingredients[${i}].name )
@@ -102,6 +104,7 @@
   num_steps=$(echo "${receipt}" | jq .spec.steps\[\].order | wc -l)
   # now let's iterate over that
   printf "Processing the instructions:\n"
   i=1
   while [ ${i} -lt ${num_steps} ]; do
       instruction=$( echo "${receipt}" | jq '.spec.steps[] | select(.order == '${i}') | { instruction | join (" ")' )
@@ -112,6 +115,7 @@
       sleep 1
       i=$(( ${i} + 1 ))
   done
   printf "Done with this receipt.\n\n"
    done
done