Skip to content

Commit 506f36b

Browse files
authored
Merge pull request #120 from cisagov/improvement/add_script_to_update_molecule_images
Add a convenience script to update molecule Docker images
2 parents 9bbd8bb + 02bd844 commit 506f36b

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

update_molecule_images.sh

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env bash
2+
3+
# Update the Docker images used in the molecule testing for this role.
4+
# Please note that this script requires the yq tool
5+
# (https://github.com/mikefarah/yq) which can be installed from brew as
6+
# yq and is available on Arch as go-yq.
7+
8+
set -o nounset
9+
set -o errexit
10+
set -o pipefail
11+
12+
# Print usage information and exit.
13+
function usage {
14+
echo "Usage:"
15+
echo " ${0##*/} [source_file]"
16+
echo
17+
echo "Arguments:"
18+
echo " source_file If specified use this file instead of the default"
19+
echo " molecule/default/molecule.yml"
20+
exit 1
21+
}
22+
23+
# Check for required external programs. If any are missing output a list of all
24+
# requirements and then exit.
25+
function check_dependencies {
26+
if [ -z "$(command -v yq)" ]; then
27+
echo "This script requires the following tools to run:"
28+
echo "- yq"
29+
exit 1
30+
fi
31+
}
32+
33+
if [ $# -gt 1 ]; then
34+
usage
35+
fi
36+
37+
if [ $# -eq 1 ]; then
38+
source_file="$1"
39+
else
40+
source_file="molecule/default/molecule.yml"
41+
fi
42+
43+
check_dependencies
44+
45+
yq '.platforms[].image' < "$source_file" | xargs -n 1 docker pull

0 commit comments

Comments
 (0)