Browse Source

new: [compose-core] add new ``stub`` service type

``stub`` services do not have any container running nor images.
They are intended to stand for externally managed services.
cache-relation
Valentin Lab 11 months ago
parent
commit
cba4f2576f
  1. 21
      bin/compose-core

21
bin/compose-core

@ -678,13 +678,13 @@ get_service_type() {
cat "$cache_file"
return 0
fi
charm=$(get_service_charm "$service") || return 1
master_target_service="$(get_top_master_service_for_service "$service")" || return 1
charm=$(get_service_charm "$master_target_service") || return 1
metadata=$(charm.metadata "$charm") || return 1
printf "%s" "$metadata" | shyaml get-value type service 2>/dev/null |
tee "$cache_file"
}
export -f get_service_type
are_files_locked_in_dir() {
local dir="$1" device hdev ldev
@ -1059,6 +1059,7 @@ get_docker_compose_links() {
master_target_service="$(get_top_master_service_for_service "$target_service")" || return 1
[ "$master_service" == "$master_target_service" ] && continue
type="$(get_service_type "$target_service")" || return 1
[ "$type" == "stub" ] && continue
[ "$type" == "run-once" ] && continue
if [ "$tech_dep" == "reversed" ]; then
deps+=("$(echo -en "$master_target_service:\n links:\n - $master_service")")
@ -1124,6 +1125,9 @@ _get_docker_compose_service_mixin() {
cat "$cache_file"
return 0
fi
type=$(get_service_type "$service") || return 1
[ "$type" == "stub" ] && return 0
master_service=$(get_top_master_service_for_service "$service") || {
err "Failed to get top master service for service $DARKYELLOW$service$NORMAL"
return 1
@ -1562,11 +1566,14 @@ run_service_hook () {
charm=$(get_service_charm "$subservice") || return 1
charm.has_hook "$charm" "$action" >/dev/null || continue
type=$(get_service_type "$subservice") || return 1
PROJECT_NAME=$(get_default_project_name) || return 1
MASTER_BASE_SERVICE_NAME=$(get_top_master_service_for_service "$subservice") || return 1
MASTER_BASE_CHARM_NAME=$(get_service_charm "$MASTER_BASE_SERVICE_NAME") || return 1
DOCKER_BASE_IMAGE=$(service_base_docker_image "$MASTER_BASE_SERVICE_NAME") || return 1
if [ "$type" != "stub" ]; then
DOCKER_BASE_IMAGE=$(service_base_docker_image "$MASTER_BASE_SERVICE_NAME") || return 1
fi
Wrap "${wrap_opts[@]}" -d "running $YELLOW$action$NORMAL hook of $DARKYELLOW$subservice$NORMAL in charm $DARKPINK$charm$NORMAL" <<EOF || return 1
@ -1919,7 +1926,10 @@ _run_service_relation () {
verb "Running ${DARKBLUE}$relation_name${NORMAL} relation-joined script" \
"for target $DARKYELLOW$target_service$NORMAL (charm $DARKPINK$target_charm$NORMAL)"
RELATION_CONFIG="$relation_dir/config_provider"
DOCKER_BASE_IMAGE=$(service_base_docker_image "$target_service") || return 1
type=$(get_service_type "$target_service") || return 1
if [ "$type" != "stub" ]; then
DOCKER_BASE_IMAGE=$(service_base_docker_image "$target_service") || return 1
fi
export DOCKER_BASE_IMAGE RELATION_CONFIG RELATION_DATA
{
(
@ -4445,6 +4455,7 @@ if [ "$is_docker_compose_action" -a "${#services_args[@]}" -gt 0 ]; then
type="$(get_service_type "$mservice")" || exit 1
## remove run-once
[ "$type" == "run-once" ] && continue
[ "$type" == "stub" ] && continue
seen[$mservice]=1
action_posargs+=("$mservice")
done

Loading…
Cancel
Save