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