Browse Source

new: dev: [compose-core] refactoring out the ``if`` condition

cache-relation
Valentin Lab 9 months ago
parent
commit
5b50f960bd
  1. 10
      bin/compose-core

10
bin/compose-core

@ -1436,7 +1436,6 @@ export -f get_build_hash
##
## Returns on stdout the name of the image if found, or an empty string if not
cache:image:registry:get() {
if [ -n "$COMPOSE_DOCKER_REGISTRY" ]; then
local charm="$1" hash="$2" service="$3"
local charm_image_name="cache/charm/$charm"
local charm_image="$charm_image_name:$hash"
@ -1454,12 +1453,12 @@ cache:image:registry:get() {
printf "%s" "$charm_image" | tee "$cache_file"
return $?
fi
if [[ "$out" != *"manifest unknown"* ]]; then
if [[ "$out" != *"manifest unknown"* ]] && [[ "$out" != *"not found"* ]]; then
print_status failure >&2
Feed >&2
err "Failed to pull image '$COMPOSE_DOCKER_REGISTRY/$charm_image'" \
"for ${DARKYELLOW}$service${NORMAL}:"
e "$out" | prefix " ${GRAY}|${NORMAL} " >&2
e "$out"$'\n' | prefix " ${GRAY}|${NORMAL} " >&2
return 1
fi
print_info "not found" >&2
@ -1471,7 +1470,6 @@ cache:image:registry:get() {
echo -n "$*${NORMAL}"
fi >&2
Feed >&2
fi
}
export -f cache:image:registry:get
@ -1636,7 +1634,7 @@ service_ensure_image_ready() {
fi
## Can we pull it ? Let's check on $COMPOSE_DOCKER_REGISTRY
if [ -n "$COMPOSE_DOCKER_REGISTRY" ]; then
img=$(cache:image:registry:get "$charm" "$hash" "$service") || {
err "Failed to get image '$charm_image_name:$hash' from registry for ${DARKYELLOW}$service${NORMAL}."
return 1
@ -1645,7 +1643,7 @@ service_ensure_image_ready() {
printf "%s" "$img" | tee "$cache_file"
return $?
}
fi
cache:image:produce "$type" "$src" "$charm" "$hash" "$service" || return 1
cache:image:registry:put "$charm" "$hash" "$service" || return 1
printf "%s" "${charm_image_name}:$hash" | tee "$cache_file"

Loading…
Cancel
Save