Browse Source

chg: better error message and error catching upon YAML merging

test
Valentin Lab 6 years ago
parent
commit
5a60c03ff9
  1. 17
      bin/compose

17
bin/compose

@ -812,6 +812,7 @@ get_docker_compose_links() {
merge_yaml_str "${deps[@]}" | tee "$cache_file" || return 1
if [ "${PIPESTATUS[0]}" != 0 ]; then
rm "$cache_file"
err "Failed to merge YAML from all ${WHITE}links${NORMAL} dependencies."
return 1
fi
}
@ -890,6 +891,7 @@ _get_docker_compose_service_mixin() {
merge_yaml_str "$base_mixin" "$links_yaml" "$docker_compose_options" || return 1
fi | tee "$cache_file"
if [ "${PIPESTATUS[0]}" != 0 ]; then
err "Failed to constitute the base YAML for service '${DARKYELLOW}$service${NORMAL}'"
rm "$cache_file"
return 1
fi
@ -949,7 +951,10 @@ get_docker_compose () {
debug " ..finished all mixins for $DARKYELLOW$target_service$NORMAL $GRAY(in $((SECONDS - start))s)$NORMAL"
done
docker_compose_services=$(merge_yaml_str "${entries[@]}") || return 1
docker_compose_services=$(merge_yaml_str "${entries[@]}") || {
err "Failed to merge YAML services entries together."
return 1
}
base_v2="version: '2.0'
networks:
@ -984,7 +989,10 @@ _get_compose_service_def_cached () {
value=$(echo "$docker_compose" | shyaml get-value "$service" 2>/dev/null)
if ! echo "$value" | shyaml get-value "charm" >/dev/null 2>&1; then
if charm.exists "$service"; then
value=$(merge_yaml <(echo "charm: $service") <(echo "$value")) || return 1
value=$(merge_yaml <(echo "charm: $service") <(echo "$value")) || {
err "Can't merge YAML infered 'charm: $service' with base ${DARKYELLOW}$service${NORMAL} YAML definition."
return 1
}
else
err "No ${WHITE}charm${NORMAL} value for service $DARKYELLOW$service$NORMAL" \
"in compose, nor same name charm found."
@ -2101,7 +2109,10 @@ _get_docker_compose_mixin_from_metadata_cached() {
image_or_build_statement="build: $(charm.get_dir "$charm")/build"
fi
if [ "$image_or_build_statement" ]; then
mixin=$(merge_yaml_str "$mixin" "$image_or_build_statement")
mixin=$(merge_yaml_str "$mixin" "$image_or_build_statement") || {
err "Failed to merge yaml with image or build YAML statement."
return 1
}
fi
echo "$mixin" | tee "$cache_file"
}

Loading…
Cancel
Save