Skip to content
This repository has been archived by the owner on Nov 20, 2023. It is now read-only.

Commit

Permalink
fix: make get_yaml_array work
Browse files Browse the repository at this point in the history
apparently it's not possible to return an array from a function
(eventhough doing so would be nice)
  • Loading branch information
xynydev committed Aug 13, 2023
1 parent e537d65 commit 2b633ff
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ set -oue pipefail
# Absolute path to recipe file
RECIPE_FILE="/usr/share/ublue-os/startingpoint/${RECIPE}"

# https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#yq-in-a-bash-loop
get_yaml_array() {
local array=()
mapfile -t array < <(yq -- "\$1" "$RECIPE_FILE")
printf '%s\n' "${array[@]}"
readarray "$1" < <(yq -o=j -I=0 "$2" "$RECIPE_FILE" )
}

get_yaml_string() {
yq -- "${1}" "${RECIPE_FILE}"
}
Expand All @@ -26,12 +26,9 @@ IMAGE_NAME="$(get_yaml_string '.name')"
echo "Building $IMAGE_NAME from Fedora $FEDORA_VERSION ($BASE_IMAGE)."

# Run each module
MODULES=$(get_yaml_array '.modules')
echo "$MODULES"
get_yaml_array MODULES '.modules[]'

for module in "${MODULES[@]}"; do
echo "$module"

TYPE=$(echo "$module" | yq '.type')

echo "Launching module of type: $TYPE"
Expand Down

0 comments on commit 2b633ff

Please sign in to comment.