mirror of
https://github.com/optim-enterprises-bv/secureblue.git
synced 2025-11-25 06:25:04 +00:00
refactor: global get_yaml_array function
This commit is contained in:
6
build.sh
6
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')
|
||||
|
||||
@@ -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"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user