diff --git a/bin/compose-core b/bin/compose-core index ffede24..9a5a29c 100755 --- a/bin/compose-core +++ b/bin/compose-core @@ -1586,15 +1586,25 @@ setup_host_resources () { } export -f setup_host_resources - -relation-get () { +## Works on stdin +cfg-get-value () { local key="$1" out - if ! out=$(cat "$RELATION_DATA_FILE" | shyaml -y get-value "$key" 2>/dev/null); then + if [ -z "$key" ]; then + yaml_get_interpret || return 1 + return 0 + fi + if ! out=$(shyaml -y get-value "$key" 2>/dev/null); then err "The key $WHITE$key$NORMAL was not found in relation's data." return 1 fi echo "$out" | yaml_get_interpret } +export -f cfg-get-value + + +relation-get () { + cfg-get-value "$1" < "$RELATION_DATA_FILE" +} export -f relation-get