diff --git a/build.sh b/build.sh index 7d33c221a0..7c0bf5ed34 100644 --- a/build.sh +++ b/build.sh @@ -14,10 +14,22 @@ MODULE_DIRECTORY="/tmp/modules" # https://mikefarah.gitbook.io/yq/usage/tips-and-tricks#yq-in-a-bash-loop get_yaml_array() { - # creates array $1 with content at key $2 from $3 + # creates array $1 with content at key $2 from $3 readarray "$1" < <(echo "$3" | yq -I=0 "$2") } + +get_config_value() { + sed -n '/^'"$1"'=/{s/'"$1"'=//;p}' +} + +set_config_value() { + CURRENT=$(get_config_value $1 $3) + sed -i 's/'"$1"'='"$CURRENT"'/'"$1"'='"$2"'/g' $3 +} + export -f get_yaml_array # this makes the function available to all modules +export -f get_config_value +export -f set_config_value # Declare dynamically generated variables as exported declare -x IMAGE_NAME BASE_IMAGE OS_VERSION