Browse Source

new: dev: propose a new generic ``cfg-get-value`` for charm usage.

hostresources
Valentin Lab 5 years ago
parent
commit
eeebb07e8a
  1. 16
      bin/compose-core

16
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

Loading…
Cancel
Save