mirror of
https://github.com/valitydev/holmes.git
synced 2024-11-06 01:45:25 +00:00
4cdec0411f
* Switch proto upstreams to valitydev: valitydev/bender-proto@38ce3ff valitydev/binbase-proto@9db92d9 valitydev/cds-proto@ed9f907 valitydev/damsel@d384c12 valitydev/fistful-proto@c45166d valitydev/limiter-proto@8c08550 valitydev/machinegun-proto@af57ba1 valitydev/msgpack-proto@8742c7a * Rewrite Dockerfile * Include protocols as full-fledged git repos * Add GH Actions CI workflow
60 lines
2.0 KiB
Bash
Executable File
60 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
CWD="$(dirname $0)"
|
|
DAMSEL="${CWD}/../damsel"
|
|
SCRIPTNAME="$(basename $0)"
|
|
|
|
source "${CWD}/lib/logging"
|
|
|
|
USAGE=$(cat <<EOF
|
|
Usage: ${SCRIPTNAME} [--force] [--set-timeout SEC | --set-deadline TS | --unset-timer | --remove] invoice-id invoice-changes
|
|
Repairs an invoice and stuffs it with the user-provided list of invoice changes.
|
|
invoice-id Invoice ID (string)
|
|
invoice-changes Invoice changes (json array)
|
|
--set-timeout To set timer to this number of seconds
|
|
--set-deadline To set timer to this time instant (RFC3339 timestamp)
|
|
--unset-timer To unset any pending timer (not an error if no timer is set)
|
|
--force To force appending changeset (which in effect turns state transitions validation off)
|
|
|
|
More information:
|
|
https://github.com/valitydev/damsel/blob/2e1dbc1a/proto/payment_processing.thrift#L1457-L1466
|
|
EOF
|
|
)
|
|
|
|
function usage {
|
|
echo "${USAGE}"
|
|
exit 127
|
|
}
|
|
|
|
getopt -T
|
|
[ $? != 4 ] && { err "Please provide modern GNU getopt implementation."; }
|
|
|
|
TEMP=$(getopt -o "" --long force,set-timeout:,set-deadline:,unset-timer -n "${SCRIPTNAME}" -- "$@")
|
|
[ $? != 0 ] && usage
|
|
|
|
eval set -- "${TEMP}"
|
|
ACTION="{}"
|
|
PARAMS="{}"
|
|
while true; do
|
|
case "$1" in
|
|
--force ) PARAMS='{"validate_transitions":false}' ; shift 1 ;;
|
|
--set-timeout ) ACTION="{\"timer\":{\"set_timer\":{\"timer\":{\"timeout\":$2}}}}" ; shift 2 ;;
|
|
--set-deadline ) ACTION="{\"timer\":{\"set_timer\":{\"timer\":{\"deadline\":\"$2\"}}}}" ; shift 2 ;;
|
|
--unset-timer ) ACTION="{\"timer\":{\"unset_timer\":{}}}" ; shift 1 ;;
|
|
-- ) shift 1 ; break ;;
|
|
* ) break ;;
|
|
esac
|
|
done
|
|
|
|
INVOICE="${1}"
|
|
[ -z "${INVOICE}" ] && usage
|
|
INVOICE_CHANGES="${2}"
|
|
[ -z "${INVOICE_CHANGES}" ] && usage
|
|
|
|
[ -f woorlrc ] && source woorlrc
|
|
|
|
"${WOORL[@]:-woorl}" \
|
|
-s "${DAMSEL}/proto/payment_processing.thrift" \
|
|
"http://${HELLGATE:-hellgate}:8022/v1/processing/invoicing" \
|
|
Invoicing Repair "\"${INVOICE}\"" "${INVOICE_CHANGES}" "${ACTION}" "${PARAMS}"
|