diff --git a/build.sh b/build.sh index 29a1798..a980201 100644 --- a/build.sh +++ b/build.sh @@ -9,8 +9,10 @@ MODULE_DIRECTORY="/tmp/modules" # https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#yq-in-a-bash-loop get_yaml_array() { - readarray "$1" < <(yq -o=j -I=0 "$2" "$RECIPE_FILE" ) + # creates array $1 with content at key $2 from $3 + readarray "$1" < <(echo "$3" | yq -o=j -I=0 "$2" ) } +export -f get_yaml_array # this makes the function available to all modules # Automatically determine which Fedora version we're building. FEDORA_VERSION="$(grep -Po '(?<=VERSION_ID=)\d+' /usr/lib/os-release)" @@ -23,7 +25,7 @@ IMAGE_NAME="$(yq '.name' "$RECIPE_FILE")" echo "Building $IMAGE_NAME from Fedora $FEDORA_VERSION ($BASE_IMAGE)." # Run each module -get_yaml_array MODULES '.modules[]' +readarray MODULES < <(yq -o=j -I=0 '.modules[]' "$RECIPE_FILE" ) for MODULE in "${MODULES[@]}"; do TYPE=$(echo "$MODULE" | yq '.type') diff --git a/modules/script/script.sh b/modules/script/script.sh index d71a78a..22fec4d 100644 --- a/modules/script/script.sh +++ b/modules/script/script.sh @@ -3,7 +3,7 @@ # Tell build process to exit if there are any errors. set -oue pipefail -readarray RUN < <(yq -o=j -I=0 '.run[]' "$1" ) +get_yaml_array RUN '.run[]' "$1" cd "$CONFIG_DIRECTORY/scripts"