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

fix: Support docker build output for Docker Desktop v4.31 #420

Closed
wants to merge 3 commits into from
Closed
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
5 changes: 5 additions & 0 deletions lib/kitchen/docker/helpers/image_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ def parse_image_id(output)
img_id = line.split(/\s+/).last
return img_id
end
# Docker ~v4.31 support
if line =~ /naming to moby-dangling@(sha256:[[:xdigit:]]{64})(?: \d*\.\ds)? done/i
img_id = line[/naming to moby-dangling@(sha256:[[:xdigit:]]{64})(?: \d*\.\ds)? done/i, 1]
return img_id
end
end
raise ActionFailed, "Could not parse Docker build output for image ID"
end
Expand Down
43 changes: 43 additions & 0 deletions lib/kitchen/transport/docker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,49 @@ def container
end
@container
end

def login_command
config = container.instance_variable_get(:@config)
login_config = config.dup
login_config[:interactive] = true
login_config[:tty] = true
login_config[:detach] = false
login_config[:username] = nil
login_cmd = build_login_command(login_config)
LoginCommand.new(login_cmd[0], login_cmd[1..-1])
end

def build_login_command(config)
# This function duplicates a lot of CliHelper functionality, but I think I'd need to refactor
# things to override some aspects of Configurable in order to reuse that code.
docker = [config[:binary].dup]
docker << "-H #{config[:socket]}" if config[:socket]
docker << "--tls" if config[:tls]
docker << "--tlsverify" if config[:tls_verify]
docker << "--tlscacert=#{config[:tls_cacert]}" if config[:tls_cacert]
docker << "--tlscert=#{config[:tls_cert]}" if config[:tls_cert]
docker << "--tlskey=#{config[:tls_key]}" if config[:tls_key]
logger.debug("docker_command: #{docker.join(" ")}")

cmd = ["exec"]
cmd << "-d" if config[:detach]
if config[:env_variables]
config[:env_variables].each do |var|
cmd << "-e #{var}"
end
end
cmd << "--privileged" if config[:privileged]
cmd << "-t" if config[:tty]
cmd << "-i" if config[:interactive]
cmd << "-u #{config[:username]}" if config[:username]
cmd << "-w #{config[:working_dir]}" if config[:working_dir]
cmd << "#{config[:container_id]}"
cmd << "/bin/bash"
cmd << "-login"
cmd << "-i"
logger.debug("build_exec_command: #{cmd.join(" ")}")
docker + cmd
end
end
end
end
Expand Down
Loading