-
Notifications
You must be signed in to change notification settings - Fork 2
/
update_molecule_images.sh
executable file
·48 lines (40 loc) · 1.21 KB
/
update_molecule_images.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#!/usr/bin/env bash
# Update the Docker images used in the molecule testing for this role.
# Please note that this script requires the yq tool
# (https://github.com/mikefarah/yq) which can be installed from brew as
# yq and is available on Arch as go-yq.
set -o nounset
set -o errexit
set -o pipefail
# Print usage information and exit.
function usage {
echo "Usage:"
echo " ${0##*/} [source_file]"
echo
echo "Arguments:"
echo " source_file If specified use this file instead of the default"
echo " molecule/default/molecule.yml"
exit 1
}
# Check for required external programs. If any are missing output a list of all
# requirements and then exit.
function check_dependencies {
if [ -z "$(command -v yq)" ]; then
echo "This script requires the following tools to run:"
echo "- yq"
exit 1
fi
}
if [ $# -gt 1 ]; then
usage
fi
if [ $# -eq 1 ]; then
source_file="$1"
else
source_file="molecule/default/molecule.yml"
fi
check_dependencies
# Note that we can't use --max-args in place of -n in the xargs
# command since the version of xargs distributed with macOS does not
# support it.
yq '.platforms[] | "\(.platform) \(.image)"' < "$source_file" | xargs -n 2 docker pull --platform