|
|
@ -1746,7 +1746,7 @@ export -f get_service_relation_tech_dep |
|
|
|
## Use compose file to get deps, and relation definition in metadata.yml |
|
|
|
## for tech-dep attribute. |
|
|
|
get_service_deps() { |
|
|
|
local service="$1" cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$@" "$ALL_RELATIONS")" |
|
|
|
local service="$1" cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$@" "$GLOBAL_ALL_RELATIONS_HASH")" |
|
|
|
if [ -e "$cache_file" ]; then |
|
|
|
# debug "$FUNCNAME: cache hit ($*)" |
|
|
|
cat "$cache_file" |
|
|
@ -1767,7 +1767,7 @@ export -f get_service_deps |
|
|
|
_rec_get_depth() { |
|
|
|
local elt=$1 dep deps max |
|
|
|
[ "${depths[$elt]}" ] && return 0 |
|
|
|
local cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$@" "$(declare -pA depths)" "$ALL_RELATIONS")" |
|
|
|
local cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$@" "$(declare -pA depths)" "$GLOBAL_ALL_RELATIONS_HASH")" |
|
|
|
if [ -e "$cache_file.depths" ]; then |
|
|
|
#debug "$FUNCNAME: cache hit ($*) - $cache_file.depths" |
|
|
|
while read-0 k v; do |
|
|
@ -1810,7 +1810,7 @@ export -f _rec_get_depth |
|
|
|
|
|
|
|
|
|
|
|
get_ordered_service_dependencies() { |
|
|
|
local services=("$@") cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$@" "$ALL_RELATIONS")" \ |
|
|
|
local services=("$@") cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$@" "$GLOBAL_ALL_RELATIONS_HASH")" \ |
|
|
|
i value key heads depths visited |
|
|
|
if [ -e "$cache_file" ]; then |
|
|
|
# debug "$FUNCNAME: cache hit ($*)" |
|
|
@ -2398,7 +2398,7 @@ export -f get_compose_relations |
|
|
|
|
|
|
|
|
|
|
|
get_all_services() { |
|
|
|
local cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$ALL_RELATIONS")" \ |
|
|
|
local cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$GLOBAL_ALL_RELATIONS_HASH")" \ |
|
|
|
s rn ts rc td services |
|
|
|
if [ -e "$cache_file" ]; then |
|
|
|
#debug "$FUNCNAME: SESSION cache hit $1" |
|
|
@ -2406,8 +2406,8 @@ get_all_services() { |
|
|
|
return 0 |
|
|
|
fi |
|
|
|
|
|
|
|
if [ -z "$ALL_RELATIONS" ]; then |
|
|
|
err "Can't access global \$ALL_RELATIONS" |
|
|
|
if [ -z "$GLOBAL_ALL_RELATIONS" ]; then |
|
|
|
err "Can't access global \$GLOBAL_ALL_RELATIONS" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
|
|
|
@ -2418,7 +2418,7 @@ get_all_services() { |
|
|
|
services["$service"]=1 |
|
|
|
echo "$service" |
|
|
|
done |
|
|
|
done < <(cat "$ALL_RELATIONS") > "$cache_file" |
|
|
|
done < <(cat "$GLOBAL_ALL_RELATIONS") > "$cache_file" |
|
|
|
|
|
|
|
cat "$cache_file" |
|
|
|
} |
|
|
@ -2426,7 +2426,7 @@ export -f get_all_services |
|
|
|
|
|
|
|
|
|
|
|
get_service_relations () { |
|
|
|
local service="$1" cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$@" "$ALL_RELATIONS")" \ |
|
|
|
local service="$1" cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$@" "$GLOBAL_ALL_RELATIONS_HASH")" \ |
|
|
|
s rn ts rc td |
|
|
|
if [ -e "$cache_file" ]; then |
|
|
|
#debug "$FUNCNAME: SESSION cache hit $1" |
|
|
@ -2434,15 +2434,15 @@ get_service_relations () { |
|
|
|
return 0 |
|
|
|
fi |
|
|
|
|
|
|
|
if [ -z "$ALL_RELATIONS" ]; then |
|
|
|
err "Can't access global \$ALL_RELATIONS" |
|
|
|
if [ -z "$GLOBAL_ALL_RELATIONS" ]; then |
|
|
|
err "Can't access global \$GLOBAL_ALL_RELATIONS" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
|
|
|
|
while read-0 s rn ts rc td; do |
|
|
|
[[ "$s" == "$service" ]] || continue |
|
|
|
printf "%s\0" "$rn" "$ts" "$rc" "$td" |
|
|
|
done < <(cat "$ALL_RELATIONS") > "$cache_file" |
|
|
|
done < <(cat "$GLOBAL_ALL_RELATIONS") > "$cache_file" |
|
|
|
|
|
|
|
cat "$cache_file" |
|
|
|
} |
|
|
@ -2480,15 +2480,15 @@ export -f get_service_relation |
|
|
|
## (base_service, relation_config) |
|
|
|
## |
|
|
|
get_service_incoming_relations() { |
|
|
|
local service="$1" relation="$2" cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$@" "$ALL_RELATIONS")" \ |
|
|
|
local service="$1" relation="$2" cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$@" "$GLOBAL_ALL_RELATIONS_HASH")" \ |
|
|
|
s rn ts rc td |
|
|
|
if [ -e "$cache_file" ]; then |
|
|
|
#debug "$FUNCNAME: SESSION cache hit $1" |
|
|
|
cat "$cache_file" |
|
|
|
return 0 |
|
|
|
fi |
|
|
|
if [ -z "$ALL_RELATIONS" ]; then |
|
|
|
err "Can't access global \$ALL_RELATIONS" |
|
|
|
if [ -z "$GLOBAL_ALL_RELATIONS" ]; then |
|
|
|
err "Can't access global \$GLOBAL_ALL_RELATIONS" |
|
|
|
return 1 |
|
|
|
fi |
|
|
|
|
|
|
@ -2497,7 +2497,7 @@ get_service_incoming_relations() { |
|
|
|
[[ "$rn" == "$relation" ]] || continue |
|
|
|
relation_data_file=$(get_relation_data_file "$s" "$ts" "$rn" "$rc") || return 1 |
|
|
|
printf "%s\0" "$s" "$(cat "$relation_data_file")" |
|
|
|
done < <(cat "$ALL_RELATIONS") > "$cache_file" |
|
|
|
done < "$GLOBAL_ALL_RELATIONS" > "$cache_file" |
|
|
|
|
|
|
|
cat "$cache_file" |
|
|
|
} |
|
|
@ -2842,14 +2842,14 @@ get_all_relations () { |
|
|
|
local cache_file="$state_tmpdir/$FUNCNAME.cache.$(H "$@" "$(declare -p without_relations)")" \ |
|
|
|
services |
|
|
|
|
|
|
|
if [ -n "$ALL_RELATIONS" ]; then |
|
|
|
cat "$ALL_RELATIONS" || return 1 |
|
|
|
if [ -n "$GLOBAL_ALL_RELATIONS" ]; then |
|
|
|
cat "$GLOBAL_ALL_RELATIONS" || return 1 |
|
|
|
return 0 |
|
|
|
fi |
|
|
|
|
|
|
|
if [ -e "${cache_file}" ]; then |
|
|
|
#debug "$FUNCNAME: SESSION cache hit $1" |
|
|
|
export ALL_RELATIONS="$cache_file" |
|
|
|
export GLOBAL_ALL_RELATIONS="$cache_file" |
|
|
|
cat "${cache_file}" |
|
|
|
return 0 |
|
|
|
fi |
|
|
@ -3127,8 +3127,10 @@ get_all_relations () { |
|
|
|
mv "${cache_file}.wip."{out,in} |
|
|
|
done |
|
|
|
|
|
|
|
export ALL_RELATIONS="$cache_file" |
|
|
|
mv "${cache_file}"{.wip.final,} || return 1 |
|
|
|
export GLOBAL_ALL_RELATIONS="$cache_file" |
|
|
|
GLOBAL_ALL_RELATIONS_HASH=$(hash_get < "$cache_file") || return 1 |
|
|
|
export GLOBAL_ALL_RELATIONS_HASH |
|
|
|
cat "$cache_file" |
|
|
|
} |
|
|
|
export -f get_all_relations |
|
|
|