Browse Source

new: dev: added ``yaml_get_values`` helper function for charm.

hostresources
Valentin Lab 6 years ago
parent
commit
bb666109a4
  1. 40
      bin/compose-core

40
bin/compose-core

@ -311,6 +311,46 @@ EOF
export -f merge_yaml_str export -f merge_yaml_str
yaml_get_values() {
local sep=${1:-$'\n'} value input type first elt
input=$(cat -)
if [ -z "$input" ] || [ "$input" == "None" ]; then
return 0
fi
type=$(e "$input" | shyaml get-type)
value=
case "$type" in
"sequence")
first=1
while read-0 elt; do
elt="$(e "$elt" | yaml_get_interpret)" || return 1
[ "$elt" ] || continue
if [ "$first" ]; then
first=
else
value+="$sep"
fi
first=
value+="$elt"
done < <(e "$input" | shyaml -y get-values-0)
;;
"struct")
while read-0 val; do
value+=$'\n'"$(e "$val" | yaml_get_interpret)" || return 1
done < <(e "$input" | shyaml -y values-0)
;;
"NoneType")
value=""
;;
"str"|*)
value+="$(e "$input" | yaml_get_interpret)"
;;
esac
e "$value"
}
export -f yaml_get_values
yaml_key_val_str() { yaml_key_val_str() {
local entries="$@" local entries="$@"

Loading…
Cancel
Save