Merge pull request #352 from anthony-roger/master

feat: add target -t option to run checks for specifics images
This commit is contained in:
Thomas Sjögren 2019-01-15 09:24:13 +01:00 committed by GitHub
commit b1bbe07902
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 2 deletions

View file

@ -46,13 +46,14 @@ usage () {
-e CHECK optional Comma delimited list of specific check(s) to exclude -e CHECK optional Comma delimited list of specific check(s) to exclude
-i INCLUDE optional Comma delimited list of patterns within a container name to check -i INCLUDE optional Comma delimited list of patterns within a container name to check
-x EXCLUDE optional Comma delimited list of patterns within a container name to exclude from check -x EXCLUDE optional Comma delimited list of patterns within a container name to exclude from check
-t TARGET optional Comma delimited list of images name to check.
EOF EOF
} }
# Get the flags # Get the flags
# If you add an option here, please # If you add an option here, please
# remember to update usage() above. # remember to update usage() above.
while getopts bhl:c:e:i:x: args while getopts bhl:c:e:i:x:t: args
do do
case $args in case $args in
b) nocolor="nocolor";; b) nocolor="nocolor";;
@ -62,6 +63,7 @@ do
e) checkexclude="$OPTARG" ;; e) checkexclude="$OPTARG" ;;
i) include="$OPTARG" ;; i) include="$OPTARG" ;;
x) exclude="$OPTARG" ;; x) exclude="$OPTARG" ;;
t) imgList="$OPTARG" ;;
*) usage; exit 1 ;; *) usage; exit 1 ;;
esac esac
done done

View file

@ -1,6 +1,19 @@
#!/bin/sh #!/bin/sh
if [ -n "$imgList" ]; then
pattern=$(echo "$imgList" | sed 's/,/ /g')
for img in $pattern; do
echo "Looking for image $img"
sha256=$(docker image ls "$img" -q)
if [ -z "$sha256" ]; then
echo "Image $img not found. Exiting."
exit 1
fi
images="$images $sha256 "
done
else
images=$(docker images -q) images=$(docker images -q)
fi
check_4() { check_4() {
logit "\n" logit "\n"