Split compose links if string values

This commit is contained in:
Chris Roberts 2017-07-31 14:23:50 -07:00
parent a7b228eb69
commit 3b4901a5b5
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