Browse Source

new: [compose-core] make ``service:relation-file`` always return an existing file

It must create it with ``compose`` / ``default-options`` values by
default if not already created.

Signed-off-by: Valentin Lab <valentin.lab@kalysto.org>
cache-relation
Valentin Lab 3 years ago
parent
commit
29423ac3b6
  1. 9
      bin/compose-core

9
bin/compose-core

@ -2148,7 +2148,7 @@ service:relation-file() {
fi
relation="${service_path##*${TRAVERSE_SEPARATOR}}"
service=$(service:traverse "${service_path%${TRAVERSE_SEPARATOR}*}") || return 1
if ! read-0 ts _ _ < <(get_service_relation "${service}" "${relation}"); then
if ! read-0 ts rc _ < <(get_service_relation "${service}" "${relation}"); then
err "Couldn't find relation ${DARKCYAN}${relation}${NORMAL}" \
"from ${DARKYELLOW}$service${NORMAL}."
return 1
@ -2157,7 +2157,12 @@ service:relation-file() {
err "Failed to find relation file"
return 1
}
echo "$relation_dir/data"
relation_file="$relation_dir/data"
if ! [ -e "$relation_file" ]; then
e "$rc" > "$relation_file"
chmod go-rwx "$relation_file" ## protecting this file
fi
echo "$relation_file"
}
export -f service:relation-file

Loading…
Cancel
Save