Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Properly match container ID when trailing content exists #13475

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion plugins/providers/docker/driver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def build(dir, **opts, &block)
# Check for podman format when it is emulating docker CLI.
# Podman outputs the full hash of the container on
# the last line after a successful build.
match = result.split.select { |str| str.match?(/[0-9a-z]{64}/) }.last
match = result.split.select { |str| str.match?(/^[0-9a-z]{64}/) }.last
return match[0..7] unless match.nil?
else
matches = result.scan(/Successfully built (.+)$/i).last
Expand Down
11 changes: 11 additions & 0 deletions test/unit/plugins/providers/docker/driver_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,17 @@

expect(container_id).to eq(cid)
end

context "if output contains extra trailing information" do
let(:stdout) { "1a2b3c4d5e6f7g8h9i10j11k12l13m14n16o17p18q19r20s21t22u23v24w25x2\nextra content\n" }
it "builds a container with podman emulating docker CLI" do
allow(subject).to receive(:podman?).and_return(true)

container_id = subject.build("/tmp/fakedir")

expect(container_id).to eq(cid)
end
end
end
end

Expand Down