Skip to content

Commit

Permalink
Fix caching of images when multiple images specified (#150)
Browse files Browse the repository at this point in the history
* Fix caching of images when multiple images specified
* Remove query parameters from filename when saving devfile icon

Signed-off-by: Angel Misevski <amisevsk@redhat.com>
  • Loading branch information
amisevsk committed Dec 3, 2019
1 parent 35e383e commit 54ac27e
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions build/scripts/cache_images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ images=$(yq -S -r '.icon' "${metas[@]}" | sort | uniq)
mkdir -p "$RESOURCES_DIR" "$TEMP_DIR"

echo "Caching images referenced in devfiles"
for image in "${images[@]}"; do
while read -r image; do
# Workaround for getting filenames through content-disposition: copy to temp
# dir and read filename before moving to /resources.
wget -P "${TEMP_DIR}" -nv --content-disposition "${image}"
Expand All @@ -40,13 +40,15 @@ for image in "${images[@]}"; do
image_dir="${RESOURCES_DIR%/}/${image_dir%/*}"
mkdir -p "$image_dir"

cached_image="${image_dir%/}/${filename}"
# Strip query and fragment components from image URL
cached_image="${image_dir%/}/${filename%%\?*}"
cached_image="${cached_image%%\#*}"
mv "$file" "$cached_image"
echo " Downloaded image $image to $cached_image"

cached_url="{{ DEVFILE_REGISTRY_URL }}/${cached_image#/}"
sed -i "s|${image}|${cached_url}|g" "${metas[@]}" "$INDEX_JSON"
echo " Updated devfiles to point at cached image"
done
done <<< "$images"

rm -rf "$TEMP_DIR"

0 comments on commit 54ac27e

Please sign in to comment.