@ -2733,7 +2733,7 @@ _run_service_action_direct() {
local service="$1" action="$2" charm _dummy project_name
shift; shift
read-0 charm || true ## against 'set -e' that could be setup in parent scripts
read-0 charm action_script_path || true ## against 'set -e' that could be setup in parent scripts
if read-0 _dummy || [ "$_dummy" ]; then
print_syntax_error "$FUNCNAME: too many arguments in action descriptor"
@ -2750,6 +2750,7 @@ _run_service_action_direct() {
export METADATA_CONFIG=$(charm.metadata "$charm")
export SERVICE_NAME=$service
export ACTION_NAME=$action
export ACTION_SCRIPT_PATH="$action_script_path"
export CONTAINER_NAME=$(get_top_master_service_for_service "$service")
export DOCKER_BASE_IMAGE=$(service_base_docker_image "$CONTAINER_NAME")
export SERVICE_DATASTORE="$DATASTORE/$service"
@ -2764,7 +2765,7 @@ _run_service_action_relation() {
local service="$1" action="$2" charm target_charm relation_name relation_config _dummy
shift; shift
read-0 charm target_service target_charm relation_name relation_config || true
read-0 charm target_service target_charm relation_name relation_config action_script_path || true
if read-0 _dummy || [ "$_dummy" ]; then
print_syntax_error "$FUNCNAME: too many arguments in action descriptor"
@ -2782,6 +2783,7 @@ _run_service_action_relation() {
export RELATION_BASE_SERVICE="$service"
export RELATION_BASE_CHARM="$charm"
export ACTION_NAME=$action
export ACTION_SCRIPT_PATH="$action_script_path"
export CONTAINER_NAME=$(get_top_master_service_for_service "$service")
export DOCKER_BASE_IMAGE=$(service_base_docker_image "$CONTAINER_NAME")
export SERVICE_DATASTORE="$DATASTORE/$service"
@ -2845,7 +2847,8 @@ export -f get_relation_data_file
has_service_action () {
local service="$1" action="$2" cache_file="$state_tmpdir/$FUNCNAME.cache.$1" \
charm target_charm relation_name target_service relation_config _tech_dep
charm target_charm relation_name target_service relation_config _tech_dep \
path
if [ -e "$cache_file" ]; then
# debug "$FUNCNAME: cache hit ($*)"
cat "$cache_file"
@ -2856,8 +2859,8 @@ has_service_action () {
## Action directly provided ?
if charm.has_direct_action "$charm" "$action" >/dev/null ; then
echo -en "direct\0$charm " | tee "$cache_file"
if path=$( charm.has_direct_action "$charm" "$action") ; then
p0 "direct" "$charm" "$path " | tee "$cache_file"
return 0
fi
@ -2865,8 +2868,8 @@ has_service_action () {
while read-0 relation_name target_service relation_config _tech_dep; do
target_charm=$(get_service_charm "$target_service") || return 1
if charm.has_relation_action "$target_charm" "$relation_name" "$action" >/dev/null ; then
echo -en "relation\0$charm\0$target_service\0$target_charm\0$relation_name\0$relation_config " | tee "$cache_file"
if path=$( charm.has_relation_action "$target_charm" "$relation_name" "$action") ; then
p0 "relation" "$charm" "$target_service" "$target_charm" "$relation_name" "$relation_config" "$path " | tee "$cache_file"
return 0
fi
done < <(get_service_relations "$service")
@ -4229,10 +4232,11 @@ if [ -z "$is_docker_compose_action" -a "$action" ]; then
read-0 action_type
case "$action_type" in
"relation")
read-0 _ target_service _target_charm relation_name
read-0 _ target_service _target_charm relation_name _ action_script_path
debug "Found action $DARKYELLOW${action_service}$NORMAL/$DARKBLUE$relation_name$NORMAL/$DARKCYAN$action$NORMAL (in $DARKYELLOW$target_service$NORMAL)"
;;
"direct")
read-0 _ action_script_path
debug "Found action $DARKYELLOW${action_service}$NORMAL.$DARKCYAN$action$NORMAL"
;;
esac
@ -4313,6 +4317,17 @@ case "$action" in
*)
if [ "$is_service_action" ]; then
full_init=true
keywords=($(egrep "^#*\s*compose:" "$action_script_path" | cut -f 2- -d:))
for keyword in "${keywords[@]}"; do
case "$keyword" in
no-hooks)
full_init=
;;
hooks)
full_init=true
;;
esac
done
fi
;;
esac