1#!/usr/bin/env bash 2# Fetch images used for e2e testing 3set -eu -o pipefail 4 5alpine_src=alpine@sha256:f006ecbb824d87947d0b51ab8488634bf69fe4094959d935c0c103f4820a417d 6alpine_dest=registry:5000/alpine:3.6 7 8busybox_src=busybox@sha256:3e8fa85ddfef1af9ca85a5cfb714148956984e02f00bec3f7f49d3925a91e0e7 9busybox_dest=registry:5000/busybox:1.27.2 10 11function fetch_tag_image { 12 local src=$1 13 local dest=$2 14 docker pull "$src" 15 docker tag "$src" "$dest" 16} 17 18function push_image { 19 local img=$1 20 docker push "$img" 21} 22 23cmd=${1-} 24case "$cmd" in 25 alpine) 26 fetch_tag_image "$alpine_src" "$alpine_dest" 27 push_image "$alpine_dest" 28 exit 29 ;; 30 busybox) 31 fetch_tag_image "$busybox_src" "$busybox_dest" 32 push_image "$busybox_dest" 33 exit 34 ;; 35 all|"") 36 fetch_tag_image "$alpine_src" "$alpine_dest" 37 push_image "$alpine_dest" 38 fetch_tag_image "$busybox_src" "$busybox_dest" 39 push_image "$busybox_dest" 40 exit 41 ;; 42 fetch-only) 43 fetch_tag_image "$alpine_src" "$alpine_dest" 44 fetch_tag_image "$busybox_src" "$busybox_dest" 45 exit 46 ;; 47 *) 48 echo "Unknown command: $cmd" 49 echo "Usage:" 50 echo " $0 [alpine | busybox | all | fetch-only]" 51 exit 1 52 ;; 53esac 54