Browse Source

new: direct action do not decorate output anymore

We couldn't use efficiently the output of direct action in scripts.
checking
Valentin Lab 5 years ago
parent
commit
06cc478ad0
  1. 36
      bin/compose-core

36
bin/compose-core

@ -2616,28 +2616,19 @@ _run_service_action_direct() {
export action_errlvl_file="$state_tmpdir/action-$service-$charm-$action-errlvl"
export state_tmpdir
{
(
set +e ## Prevents unwanted leaks from parent shell
export COMPOSE_CONFIG=$(get_compose_yml_content)
export METADATA_CONFIG=$(charm.metadata "$charm")
export SERVICE_NAME=$service
export ACTION_NAME=$action
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"
export SERVICE_CONFIGSTORE="$CONFIGSTORE/$service"
exname="$exname $ACTION_NAME $SERVICE_NAME" \
stdbuf -oL -eL bash -c 'charm.run_direct_action "$@"' -- "$charm" "$action" "$@"
echo "$?" > "$action_errlvl_file"
) | logstdout "$DARKYELLOW$service$NORMAL/${DARKCYAN}$action${NORMAL} ${GREEN}@${NORMAL}"
} 3>&1 1>&2 2>&3 | logstderr "$DARKYELLOW$service$NORMAL/${DARKCYAN}$action${NORMAL} ${RED}@$NORMAL" 3>&1 1>&2 2>&3
if ! [ -e "$action_errlvl_file" ]; then
err "Action $DARKYELLOW$service$NORMAL:$DARKCYAN$action$NORMAL has failed without having time" \
"to output an errlvl"
return 1
fi
return "$(cat "$action_errlvl_file")"
(
set +e ## Prevents unwanted leaks from parent shell
export COMPOSE_CONFIG=$(get_compose_yml_content)
export METADATA_CONFIG=$(charm.metadata "$charm")
export SERVICE_NAME=$service
export ACTION_NAME=$action
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"
export SERVICE_CONFIGSTORE="$CONFIGSTORE/$service"
exname="$exname $ACTION_NAME $SERVICE_NAME" \
stdbuf -oL -eL bash -c 'charm.run_direct_action "$@"' -- "$charm" "$action" "$@"
)
}
export -f _run_service_action_direct
@ -2779,7 +2770,6 @@ run_service_action () {
return 1
fi
Section "running $DARKYELLOW$service$NORMAL/$DARKCYAN$action$NORMAL ($action_type)"; Feed
"_run_service_action_${action_type}" "$service" "$action" "$@"
} < <(has_service_action "$service" "$action")

Loading…
Cancel
Save