diff --git a/scripts/exports.sh b/scripts/exports.sh index c0c9569d..e50298ee 100644 --- a/scripts/exports.sh +++ b/scripts/exports.sh @@ -18,6 +18,24 @@ get_yaml_array() { readarray -t arr < <(echo "$module_config" | yq -I=0 "$jq_query") } +# Function to retrieve module configs and populate an array +# Arguments: +# 1. Variable name to store result +# 2. jq query +# 3. Module config content +get_json_array() { + local -n arr=$1 + local jq_query=$2 + local module_config=$3 + + if [[ -z $jq_query || -z $module_config ]]; then + echo "Usage: get_json_array VARIABLE_TO_STORE_RESULTS JQ_QUERY MODULE_CONFIG" >&2 + return 1 + fi + + readarray -t arr < <(echo "$module_config" | jq "$jq_query") +} + color_string() { local string="$1" local color_code="$2"