Merge pull request #8838 from chrisroberts/docker-compose/relative-volumes
Expand relative volume paths for compose on current cwd
This commit is contained in:
commit
e3231615ef
|
@ -94,16 +94,16 @@ module VagrantPlugins
|
|||
ports = Array(params[:ports])
|
||||
volumes = Array(params[:volumes]).map do |v|
|
||||
v = v.to_s
|
||||
host, guest = v.split(":", 2)
|
||||
if v.include?(":") && (Vagrant::Util::Platform.windows? || Vagrant::Util::Platform.wsl?)
|
||||
host, guest = v.split(":", 2)
|
||||
host = Vagrant::Util::Platform.windows_path(host)
|
||||
# NOTE: Docker does not support UNC style paths (which also
|
||||
# means that there's no long path support). Hopefully this
|
||||
# will be fixed someday and the gsub below can be removed.
|
||||
host.gsub!(/^[^A-Za-z]+/, "")
|
||||
v = [host, guest].join(":")
|
||||
end
|
||||
v
|
||||
host = @machine.env.cwd.join(host).to_s
|
||||
"#{host}:#{guest}"
|
||||
end
|
||||
cmd = Array(params.fetch(:cmd))
|
||||
env = Hash[*params.fetch(:env).flatten.map(&:to_s)]
|
||||
|
|
|
@ -41,6 +41,7 @@ describe VagrantPlugins::DockerProvider::Driver::Compose do
|
|||
allow(Vagrant::Util::Which).to receive(:which).and_return("/dev/null/docker-compose")
|
||||
allow(env).to receive(:lock).and_yield
|
||||
allow(Pathname).to receive(:new).with(local_data_path).and_return(local_data_path)
|
||||
allow(Pathname).to receive(:new).with('/host/path').and_call_original
|
||||
allow(local_data_path).to receive(:join).and_return(data_directory)
|
||||
allow(data_directory).to receive(:mkpath)
|
||||
allow(FileUtils).to receive(:mv)
|
||||
|
@ -93,6 +94,18 @@ describe VagrantPlugins::DockerProvider::Driver::Compose do
|
|||
end
|
||||
end
|
||||
|
||||
context 'with relative path in share folders' do
|
||||
before do
|
||||
params[:volumes] = './path:guest/path'
|
||||
allow(Pathname).to receive(:new).with('./path').and_call_original
|
||||
allow(Pathname).to receive(:new).with('/compose/cwd/path').and_call_original
|
||||
end
|
||||
|
||||
it 'should expand the relative host directory' do
|
||||
expect(docker_yml).to receive(:write).with(%r{/compose/cwd/path})
|
||||
end
|
||||
end
|
||||
|
||||
it 'links containers' do
|
||||
params[:links].each do |link|
|
||||
expect(docker_yml).to receive(:write).with(/#{link}/)
|
||||
|
|
Loading…
Reference in New Issue