Browse Source

chg: dev: refactor out ``setup_host_resource``.

raw-remaining-args
Valentin Lab 8 years ago
parent
commit
f1d165765d
  1. 53
      bin/compose

53
bin/compose

@ -1162,8 +1162,35 @@ host_resource_get_git-sub() {
export -f host_resource_get_git-sub
setup_host_resource () {
local service="$1" service_def location get cfg
service_def=$(get_compose_service_def "$subservice") || return 1
while read-0 location cfg; do
## XXXvlab: will it be a git resources always ?
if [ -d "$location" -a ! -d "$location/.git" ]; then
err "Hum, location '$location' does not seem to be a git directory."
return 1
fi
if [ -d "$location" ]; then
info "host resource '$location' already set up."
continue
fi
get=$(echo "$cfg" | shyaml get-value get 2>/dev/null)
if [ -z "$get" ]; then
err "No host directory '$location' found, and no ${WHITE}source$NORMAL" \
"specified for $DARKYELLOW$subservice$NORMAL."
return 1
fi
host_resource_get "$location" "$get" || return 1
done < <(echo "$service_def" | shyaml key-values-0 host-resources 2>/dev/null)
}
export -f setup_host_resource
setup_host_resources () {
local services="$1" action="$2" loaded location cfg
local services="$1" loaded
declare -A loaded
for service in $services; do
@ -1174,33 +1201,13 @@ setup_host_resources () {
## requirements.
continue
fi
service_def=$(get_compose_service_def "$subservice") || return 1
while read-0 location cfg; do
## XXXvlab: will it be a git resources always ?
if [ -d "$location" -a ! -d "$location/.git" ]; then
err "Hum, location '$location' does not seem to be a git directory."
return 1
fi
if [ -d "$location" ]; then
info "host resource '$location' already set up."
continue
fi
get=$(echo "$cfg" | shyaml get-value get 2>/dev/null)
if [ -z "$get" ]; then
err "No host directory '$location' found, and no ${WHITE}source$NORMAL" \
"specified for $DARKYELLOW$subservice$NORMAL."
return 1
fi
host_resource_get "$location" "$get" || return 1
done < <(echo "$service_def" | shyaml key-values-0 host-resources 2>/dev/null)
setup_host_resource "$service"
loaded[$subservice]=1
done
done
return 0
}
export -f setup_host_resources
relation-get () {

Loading…
Cancel
Save