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:
2024-08-21 18:26:07 -07:00
parent 6d5185b63c
commit 29d2921dd8

View File

@@ -669,8 +669,8 @@ function lib_fetch::__fetch_price()
for _api in "${global_arg_api[@]}"; do for _api in "${global_arg_api[@]}"; do
if ! lib_fetch::__parse_yaml "get-value" "price.${_api}" &>/dev/null; then if [[ $(lib_fetch::__parse_yaml "get-value" "price.${_api}" 2>/dev/null) == "null" ]]; then
lib_utils::print_warning "'${_api}' price API is not set" lib_utils::print_warning "price.${_api} is not set"
continue continue
fi fi
@@ -682,15 +682,17 @@ function lib_fetch::__fetch_price()
case "$_member" in case "$_member" in
key) 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) asset)
if ! lib_fetch::__parse_yaml "get-value" "price.${_api}.${_member}" | grep -q "^- "; then if [[ "$_value" =~ (^null$|^[^- ]) ]]; then
lib_utils::die_fatal "Invalid asset sequence!" lib_utils::die_fatal "${_api} has invalid asset sequence"
fi fi
;; ;;
*) *)
lib_utils::die_fatal "${_api} has invalid member: ${_member}" lib_utils::die_fatal "price.${_api}.${_member} is invalid"
;; ;;
esac esac