Add docker cap to windows to detect daemon and fix whitespace

This commit is contained in:
Joe Pleso 2017-12-15 12:39:34 -05:00 committed by Brian Cain
parent b75732416c
commit c882d888a7
No known key found for this signature in database
GPG Key ID: 43D51080D357A001
5 changed files with 25 additions and 10 deletions

View File

@ -33,7 +33,7 @@ module VagrantPlugins
if recurse if recurse
ret_cmd = "rm \"#{dir}\" -recurse -force" ret_cmd = "rm \"#{dir}\" -recurse -force"
else else
ret_cmd = "rm \"#{dir}\" -force" ret_cmd = "if (Test-Path #{dir}) {Remove-Item #{dir} -force}"
end end
return ret_cmd return ret_cmd
end end

View File

@ -0,0 +1,13 @@
module VagrantPlugins
module DockerProvisioner
module Cap
module Windows
module DockerDaemonRunning
def self.docker_daemon_running(machine)
machine.communicate.test("tasklist | find \"`\"dockerd`\"\"")
end
end
end
end
end
end

View File

@ -127,12 +127,11 @@ module VagrantPlugins
def create_container(config) def create_container(config)
args = container_run_args(config) args = container_run_args(config)
@machine.communicate.sudo %[ @machine.communicate.sudo %[rm -f #{config[:cidfile]}
rm -f #{config[:cidfile]} ]
docker run #{args} @machine.communicate.sudo %[docker run #{args}
] ]
name = container_name(config)
sha = Digest::SHA1.hexdigest(args) sha = Digest::SHA1.hexdigest(args)
container_data_path(config).open("w+") do |f| container_data_path(config).open("w+") do |f|
f.write(sha) f.write(sha)

View File

@ -54,6 +54,11 @@ module VagrantPlugins
Cap::Linux::DockerDaemonRunning Cap::Linux::DockerDaemonRunning
end end
guest_capability("windows", "docker_daemon_running") do
require_relative "cap/windows/docker_daemon_running"
Cap::Windows::DockerDaemonRunning
end
provisioner(:docker) do provisioner(:docker) do
require_relative "provisioner" require_relative "provisioner"
Provisioner Provisioner

View File

@ -65,11 +65,9 @@ describe VagrantPlugins::CommunicatorWinRM::CommandFilter, unit: true do
it 'filters out rm commands' do it 'filters out rm commands' do
expect(subject.filter('rm /some/dir')).to eq( expect(subject.filter('rm /some/dir')).to eq(
"rm \"/some/dir\" -force") "if (Test-Path /some/dir) {Remove-Item /some/dir -force}")
expect(subject.filter('rm -f /some/dir')).to eq( expect(subject.filter('rm -f /some/dir')).to eq(
"rm \"/some/dir\" -force") "if (Test-Path /some/dir) {Remove-Item /some/dir -force}")
expect(subject.filter('rm -f "/some/dir"')).to eq(
"rm \"/some/dir\" -force")
end end
it 'filters out mkdir commands' do it 'filters out mkdir commands' do