From 4b99efdff5ee9c19f3ec4285a70632945f914c4b Mon Sep 17 00:00:00 2001 From: Valentin Lab Date: Wed, 4 Oct 2023 08:45:11 +0200 Subject: [PATCH] fix: dev: improve compatibility outside of VPS layouts --- bin/vps | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/bin/vps b/bin/vps index 51c9841..dd49912 100755 --- a/bin/vps +++ b/bin/vps @@ -688,11 +688,22 @@ export -f compose:charm:container_first compose:get_url() { local project_name="$1" service="$2" data_file network ip - data_file="/var/lib/compose/relations/${project_name}/${service}-frontend/web-proxy/data" - if [ -e "$data_file" ]; then + data_dir=("/var/lib/compose/relations/${project_name}/${service}-"*"/web-proxy") + if [ "${#data_dir[@]}" -gt 1 ]; then + err "More than one web-proxy relation." \ + "Current 'vps' algorithm is insufficient" \ + "to figure out which relation is concerned" + return 1 + fi + data_file="${data_dir[0]}/data" + if [ -d "${data_file%/*}" ]; then ( set -o pipefail - cat "$data_file" | shyaml get-value url + ## users can't cat directly the content + docker run --rm \ + -v "${data_file%/*}":/tmp/dummy alpine \ + cat "/tmp/dummy/${data_file##*/}" | + shyaml get-value url ) else ## Assume there are no frontend relation here, the url is direct IP