Merge pull request #8837 from chrisroberts/docker-compose/links

Split compose links if string values
This commit is contained in:
Chris Roberts 2017-08-21 13:21:09 -07:00 committed by GitHub
commit 3f8cbb121a
2 changed files with 20 additions and 2 deletions

View File

@ -83,7 +83,14 @@ module VagrantPlugins
# need to worry about uniqueness with compose
name = machine.name.to_s
image = params.fetch(:image)
links = params.fetch(:links)
links = Array(params.fetch(:links, [])).map do |link|
case link
when Array
link
else
link.to_s.split(":")
end
end
ports = Array(params[:ports])
volumes = Array(params[:volumes]).map do |v|
v = v.to_s

View File

@ -82,11 +82,22 @@ describe VagrantPlugins::DockerProvider::Driver::Compose do
expect(docker_yml).to receive(:write).with(/#{params[:volumes]}/)
end
context 'when links are provided as strings' do
before{ params[:links] = ["linkl1:linkr1", "linkl2:linkr2"] }
it 'links containers' do
params[:links].flatten.map{|l| l.split(':')}.each do |link|
expect(docker_yml).to receive(:write).with(/#{link}/)
end
subject.create(params)
end
end
it 'links containers' do
params[:links].each do |link|
expect(docker_yml).to receive(:write).with(/#{link}/)
subject.create(params)
end
subject.create(params)
end
it 'sets environmental variables' do