fix installer image retag
This commit is contained in:
parent
6c45cc94f3
commit
d5270308d6
@ -342,21 +342,54 @@ install_docker_if_missing() {
|
||||
load_installer_images() {
|
||||
require_cmd docker
|
||||
shopt -s nullglob
|
||||
local image
|
||||
local image load_output desired_tag
|
||||
local found=0
|
||||
for image in "$INSTALLER_ROOT"/images/*.tar "$INSTALLER_ROOT"/images/*.tar.gz; do
|
||||
found=1
|
||||
log "loading docker image: $image"
|
||||
if [[ "$image" == *.gz ]]; then
|
||||
gzip -dc "$image" | docker load
|
||||
load_output="$(gzip -dc "$image" | docker load)"
|
||||
else
|
||||
docker load -i "$image"
|
||||
load_output="$(docker load -i "$image")"
|
||||
fi
|
||||
printf '%s\n' "$load_output"
|
||||
desired_tag=""
|
||||
case "$(basename "$image")" in
|
||||
"${image_tar:-}")
|
||||
desired_tag="${image_tag:-$RPKI_IMAGE}"
|
||||
;;
|
||||
"${prometheus_image_tar:-}")
|
||||
desired_tag="${prometheus_image:-$PROMETHEUS_IMAGE}"
|
||||
;;
|
||||
"${grafana_image_tar:-}")
|
||||
desired_tag="${grafana_image:-$GRAFANA_IMAGE}"
|
||||
;;
|
||||
esac
|
||||
if [[ -n "$desired_tag" ]]; then
|
||||
ensure_loaded_image_tag "$desired_tag" "$load_output" "$image"
|
||||
fi
|
||||
done
|
||||
shopt -u nullglob
|
||||
(( found == 1 )) || warn "no image tar found under $INSTALLER_ROOT/images"
|
||||
}
|
||||
|
||||
ensure_loaded_image_tag() {
|
||||
local desired_tag="$1"
|
||||
local load_output="$2"
|
||||
local image_path="$3"
|
||||
if docker image inspect "$desired_tag" >/dev/null 2>&1; then
|
||||
return 0
|
||||
fi
|
||||
local loaded_ref=""
|
||||
loaded_ref="$(printf '%s\n' "$load_output" | awk -F'Loaded image: ' '/Loaded image: / {print $2; exit}')"
|
||||
if [[ -z "$loaded_ref" ]]; then
|
||||
loaded_ref="$(printf '%s\n' "$load_output" | awk -F'Loaded image ID: ' '/Loaded image ID: / {print $2; exit}')"
|
||||
fi
|
||||
[[ -n "$loaded_ref" ]] || die "unable to determine loaded image reference for $image_path"
|
||||
log "tagging loaded image for package use: source=$loaded_ref target=$desired_tag"
|
||||
docker tag "$loaded_ref" "$desired_tag"
|
||||
}
|
||||
|
||||
ensure_binfmt_if_needed() {
|
||||
require_cmd docker
|
||||
load_env
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user