Skip to content

Commit

Permalink
Fix get_config_value
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewbattat committed Jan 17, 2025
1 parent b9ae504 commit f12e134
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions ic-os/components/misc/config/setupos/config.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,17 @@
# Arguments:
# $1 - JSON path to the desired value (e.g., '.icos_settings.nns_urls')
# Returns:
# If key not found or value is "null", returns empty string. Otherwise, returns value
# If key is not found or value is "null", returns empty string.
# Otherwise, returns value.
function get_config_value() {
local CONFIG_FILE="/var/ic/config/config.json"
local key=$1
jq -re "${key}" "${CONFIG_FILE}" 2>/dev/null || echo ""

local value=$(jq -r "${key}" "${CONFIG_FILE}")

if [[ "${value}" == "null" ]]; then
echo ""
else
echo "${value}"
fi
}

0 comments on commit f12e134

Please sign in to comment.