forked from EvergreenCrypto/docker-finance
container: lib_fetch: fix price parsing
- Fix check if price API is not set - Fix check for invalid asset sequence - Improve log messages
This commit is contained in:
@@ -669,8 +669,8 @@ function lib_fetch::__fetch_price()
|
||||
|
||||
for _api in "${global_arg_api[@]}"; do
|
||||
|
||||
if ! lib_fetch::__parse_yaml "get-value" "price.${_api}" &>/dev/null; then
|
||||
lib_utils::print_warning "'${_api}' price API is not set"
|
||||
if [[ $(lib_fetch::__parse_yaml "get-value" "price.${_api}" 2>/dev/null) == "null" ]]; then
|
||||
lib_utils::print_warning "price.${_api} is not set"
|
||||
continue
|
||||
fi
|
||||
|
||||
@@ -682,15 +682,17 @@ function lib_fetch::__fetch_price()
|
||||
|
||||
case "$_member" in
|
||||
key)
|
||||
[[ "$_value" == "null" ]] && lib_utils::print_warning "${_api} has empty ${_member}"
|
||||
if [[ "$_value" == "null" ]]; then
|
||||
lib_utils::print_warning "price.${_api}.${_member} is not set"
|
||||
fi
|
||||
;;
|
||||
asset)
|
||||
if ! lib_fetch::__parse_yaml "get-value" "price.${_api}.${_member}" | grep -q "^- "; then
|
||||
lib_utils::die_fatal "Invalid asset sequence!"
|
||||
if [[ "$_value" =~ (^null$|^[^- ]) ]]; then
|
||||
lib_utils::die_fatal "${_api} has invalid asset sequence"
|
||||
fi
|
||||
;;
|
||||
*)
|
||||
lib_utils::die_fatal "${_api} has invalid member: ${_member}"
|
||||
lib_utils::die_fatal "price.${_api}.${_member} is invalid"
|
||||
;;
|
||||
esac
|
||||
|
||||
|
||||
Reference in New Issue
Block a user