Browse Source

new: support for type of service ``run-once`` through hook ``dc-pre-run`` and removal of auto-populated ``up``.

test
Valentin Lab 6 years ago
parent
commit
189dc1daf4
  1. 34
      bin/compose

34
bin/compose

@ -2880,6 +2880,7 @@ export DOCKER_DATASTORE=${DOCKER_DATASTORE:-/srv/docker-datastore}
COMPOSE_YML_FILE=$(get_compose_yml_location) || exit 1 COMPOSE_YML_FILE=$(get_compose_yml_location) || exit 1
COMPOSE_YML_CONTENT=$(get_compose_yml_content) || exit 1
export COMPOSE_YML_FILE COMPOSE_YML_CONTENT export COMPOSE_YML_FILE COMPOSE_YML_CONTENT
@ -2910,12 +2911,28 @@ if [ -z "$is_docker_compose_action" -a "$action" ]; then
die "Unknown action '${DARKCYAN}$action$NORMAL': It doesn't match any docker-compose commands nor inner charm actions." die "Unknown action '${DARKCYAN}$action$NORMAL': It doesn't match any docker-compose commands nor inner charm actions."
fi fi
else else
if [[ "$action" =~ (up|ps) && "${#services_args[@]}" == 0 ]]; then
services_args=($(echo "$COMPOSE_YML_CONTENT" | shyaml keys))
case "$action" in
ps)
if [ "${#services_args[@]}" == 0 ]; then
services_args=($(printf "%s" "$COMPOSE_YML_CONTENT" | shyaml keys 2>/dev/null)) || true
fi fi
if [ "$action" == "config" ]; then
services_args=("${action_posargs[@]}")
;;
up)
if [ "${#services_args[@]}" == 0 ]; then
while read-0 service; do
charm=$(get_service_charm "$service")
metadata=$(charm.metadata "$charm")
type="$(printf "%s" "$metadata" | shyaml get-value type 2>/dev/null)" || true
if [ "$type" != "run-once" ]; then
services_args+=("$service")
fi
done < <(printf "%s" "$COMPOSE_YML_CONTENT" | shyaml keys-0 2>/dev/null)
fi fi
;;
config)
services_args=("${action_posargs[@]}")
;;
esac
if [ "$is_docker_compose_action" -a "${#services_args[@]}" -gt 0 ]; then if [ "$is_docker_compose_action" -a "${#services_args[@]}" -gt 0 ]; then
services=($(get_master_services "${services_args[@]}")) || exit 1 services=($(get_master_services "${services_args[@]}")) || exit 1
action_posargs+=("${services[@]}") action_posargs+=("${services[@]}")
@ -2981,6 +2998,15 @@ if [ "$full_init" ]; then
fi fi
if [ "$action" == "run" ]; then
charm=$(get_service_charm "${services_args[0]}") || exit 1
metadata=$(charm.metadata "$charm") || exit 1
type="$(printf "%s" "$metadata" | shyaml get-value type 2>/dev/null)" || true
if [ "$type" == "run-once" ]; then
run_service_hook dc-pre-run "${services_args[@]}" || exit 1
fi
fi
export SERVICE_PACK="${services_args[*]}" export SERVICE_PACK="${services_args[*]}"

Loading…
Cancel
Save