|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# Copyright 2025 The Kubernetes Authors. |
| 4 | +# |
| 5 | +# Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | +# you may not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, software |
| 12 | +# distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | +# See the License for the specific language governing permissions and |
| 15 | +# limitations under the License. |
| 16 | + |
| 17 | +# kind:prepullAdditionalImages pre-pull all the additional (not Kindest/node) images that will be used in the e2e, thus making |
| 18 | +# the actual test run less sensible to the network speed. |
| 19 | +kind:prepullAdditionalImages () { |
| 20 | + # Pulling cert manager images so we can pre-load in kind nodes |
| 21 | + kind::prepullImage "quay.io/jetstack/cert-manager-cainjector:v1.19.1" |
| 22 | + kind::prepullImage "quay.io/jetstack/cert-manager-webhook:v1.19.1" |
| 23 | + kind::prepullImage "quay.io/jetstack/cert-manager-controller:v1.19.1" |
| 24 | + |
| 25 | + # Pull all images defined in DOCKER_PRELOAD_IMAGES. |
| 26 | + for IMAGE in $(grep DOCKER_PRELOAD_IMAGES: < "$E2E_CONF_FILE" | sed -E 's/.*\[(.*)\].*/\1/' | tr ',' ' '); do |
| 27 | + kind::prepullImage "${IMAGE}" |
| 28 | + done |
| 29 | +} |
| 30 | + |
| 31 | +# kind:prepullImage pre-pull a docker image if no already present locally. |
| 32 | +# The result will be available in the retVal value which is accessible from the caller. |
| 33 | +kind::prepullImage () { |
| 34 | + local image=$1 |
| 35 | + image="${image//+/_}" |
| 36 | + |
| 37 | + retVal=0 |
| 38 | + if [[ "$(docker images -q "$image" 2> /dev/null)" == "" ]]; then |
| 39 | + echo "+ Pulling $image" |
| 40 | + docker pull "$image" || retVal=$? |
| 41 | + else |
| 42 | + echo "+ image $image already present in the system, skipping pre-pull" |
| 43 | + fi |
| 44 | +} |
0 commit comments