Browse Source

new: added labels to attach important information from compose on running containers.

raw-remaining-args
Valentin Lab 6 years ago
parent
commit
b65c5b73c7
  1. 17
      bin/compose

17
bin/compose

@ -773,6 +773,11 @@ _get_docker_compose_service_mixin() {
## The compose part
base_mixin="$master_charm:
labels:
- \"compose.service=$service\"
- \"compose.master-charm=${master_charm}\"
- \"compose.project=$(get_default_project_name)\""
links_yaml=$(get_docker_compose_links "$service") || return 1
docker_compose_options=$(_get_docker_compose_opts "$service") || return 1
@ -785,9 +790,9 @@ _get_docker_compose_service_mixin() {
## Merge results
if [ "$charm_part" ]; then
charm_yaml="$(yaml_key_val_str "$master_charm" "$charm_part")" || return 1
merge_yaml_str "$links_yaml" "$charm_yaml" "$docker_compose_options" || return 1
merge_yaml_str "$base_mixin" "$links_yaml" "$charm_yaml" "$docker_compose_options" || return 1
else
echo "$links_yaml"
merge_yaml_str "$base_mixin" "$links_yaml" "$docker_compose_options" || return 1
fi | tee "$cache_file"
if [ "${PIPESTATUS[0]}" != 0 ]; then
rm "$cache_file"
@ -1885,7 +1890,7 @@ _get_docker_compose_mixin_from_metadata_cached() {
return 0
fi
mixin=
mixin=$(echo -en "labels:\n - \"compose.charm=$charm\"")
if [ "$metadata" ]; then
## resources to volumes
volumes=$(
@ -1910,7 +1915,11 @@ _get_docker_compose_mixin_from_metadata_cached() {
done < <(echo "$metadata" | shyaml get-values-0 "charm-resources" 2>/dev/null)
) || return 1
if [ "$volumes" ]; then
mixin=$(echo -en "volumes:\n$volumes")
mixin=$(merge_yaml_str "$mixin" "$(echo -en "volumes:\n$volumes")") || {
err "Failed to merge mixin with ${WHITE}docker-compose${NORMAL} option" \
"from charm ${DARKYELLOW}$charm$NORMAL."
return 1
}
fi
docker_compose=$(echo "$metadata" | shyaml get-value -y "docker-compose" 2>/dev/null)

Loading…
Cancel
Save