Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion tools/scan-images.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,14 @@ rm -rf image-scan-output
mkdir -p image-scan-output

# Get built container images
docker image ls --filter "reference=ark.stackhpc.com/stackhpc-dev/*:$2*" > $1-scanned-container-images.txt
output_file="$1-scanned-container-images.txt"

docker image ls \
--filter "reference=ark.stackhpc.com/stackhpc-dev/*:$2*" \
--format "{{.Repository}}:{{.Tag}}" \
> "$output_file"
Comment on lines +26 to +29
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

Using --format is a great improvement for robustness. However, this change is incomplete as it doesn't update the logic that parses the command's output. The parsing on line 34 is now incorrect and will fail for image names that include a port in the registry name (e.g., my.registry:5000/image:tag) due to the cut -f 1,2 -d: command.

To complete this fix, please also update line 34 in this PR. It should be simplified to:

images=$(cat "$output_file")

This will correctly read the image names that are already formatted by the docker image ls command. Note that on line 34, $1-scanned-container-images.txt should also be replaced with $output_file for consistency.


cat "$output_file"

# Make a file of imagename:tag
images=$(grep --invert-match --no-filename ^REPOSITORY $1-scanned-container-images.txt | sed 's/ \+/:/g' | cut -f 1,2 -d:)
Expand Down
Loading