chore: Add get_json_array bash function for migration to jq
This commit is contained in:
parent
d9caf26ee1
commit
20550f22aa
1 changed files with 18 additions and 0 deletions
|
|
@ -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"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue