Skip to content

Commit

Permalink
fix: parse_image_id: Process "docker build" output in reverse line or…
Browse files Browse the repository at this point in the history
…der (#400)

When using a custom dockerfile which installs Python modules using pip,
the output will sometimes contain the line:

Successfully built module_name

Since this matches the regex, it causes the module name to be
incorrectly identified as the image ID, which will cause kitchen-docker
to fail the "docker run" as it will not have a valid Docker image ID.

This commit processes the "docker build" output in reverse line order,
which will ensure that the correct line is matched.

Co-authored-by: Erik Johnson <erik.johnson@centurylink.com>
  • Loading branch information
terminalmage and Erik Johnson committed Jun 14, 2023
1 parent 97ecb5b commit 380bf91
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/kitchen/docker/helpers/image_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ module ImageHelper
include Kitchen::Docker::Helpers::ContainerHelper

def parse_image_id(output)
output.each_line do |line|
output.split("\n").reverse_each do |line|
if line =~ /writing image (sha256:[[:xdigit:]]{64})(?: \d*\.\ds)? done/i
img_id = line[/writing image (sha256:[[:xdigit:]]{64})(?: \d*\.\ds)? done/i,1]
return img_id
Expand Down

0 comments on commit 380bf91

Please # to comment.