big update based on real wokr
This commit is contained in:
@@ -208,6 +208,29 @@ render_kind_config() {
|
||||
"$KIND_CONFIG"
|
||||
}
|
||||
|
||||
# Render an addon's manifest (a .yaml beside its .sh) to stdout. Every ${NAME}, or
|
||||
# ${NAME:-default}, is filled from the loaded config or the calling script's variables;
|
||||
# a NAME with neither is an error, so a typo never becomes an empty image. $VAR and
|
||||
# $(VAR) are left alone: they belong to the container. Notes: docs/notes/addons.md
|
||||
render_manifest() {
|
||||
local file="$1" text ref key def val
|
||||
text=$(<"$file") || return 1
|
||||
while IFS= read -r ref; do
|
||||
key=${ref#\$\{}; key=${key%\}}; def=""
|
||||
if [[ $key == *:-* ]]; then def=${key#*:-}; key=${key%%:-*}; fi
|
||||
if [ -n "${!key:-}" ]; then
|
||||
val=${!key}
|
||||
elif [[ $ref == *:-* ]]; then
|
||||
val=$def
|
||||
else
|
||||
echo "render_manifest: $file needs \${$key}, which nothing sets" >&2
|
||||
return 1
|
||||
fi
|
||||
text=${text//"$ref"/"$val"}
|
||||
done < <(grep -oE '\$\{[A-Za-z_][A-Za-z0-9_]*(:-[^}]*)?\}' "$file" | sort -u)
|
||||
printf '%s\n' "$text"
|
||||
}
|
||||
|
||||
_config_restore() {
|
||||
local line
|
||||
while IFS= read -r line; do
|
||||
|
||||
Reference in New Issue
Block a user