From 97341c3234bccc29893715147d041cc387201251 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Pervill=C3=A9?= Date: Mon, 29 Sep 2014 18:46:01 +0200 Subject: [PATCH] providers/docker: allow multiple links to same backend (different aliases). --- plugins/providers/docker/action/create.rb | 4 ++-- test/unit/plugins/providers/docker/driver_test.rb | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/plugins/providers/docker/action/create.rb b/plugins/providers/docker/action/create.rb index e960f10b0..dcf92ce44 100644 --- a/plugins/providers/docker/action/create.rb +++ b/plugins/providers/docker/action/create.rb @@ -96,10 +96,10 @@ module VagrantPlugins image = @env[:create_image] image ||= @provider_config.image - links = {} + links = [] @provider_config._links.each do |link| parts = link.split(":", 2) - links[parts[0]] = parts[1] + links << parts end { diff --git a/test/unit/plugins/providers/docker/driver_test.rb b/test/unit/plugins/providers/docker/driver_test.rb index 337436a51..1f0ea3ece 100644 --- a/test/unit/plugins/providers/docker/driver_test.rb +++ b/test/unit/plugins/providers/docker/driver_test.rb @@ -17,7 +17,7 @@ describe VagrantPlugins::DockerProvider::Driver do ports: '8080:80', volumes: '/host/path:guest/path', detach: true, - links: {janis: 'joplin'}, + links: [[:janis, 'joplin'], [:janis, 'janis']], env: {key: 'value'}, name: cid, hostname: 'jimi-hendrix', @@ -43,7 +43,9 @@ describe VagrantPlugins::DockerProvider::Driver do end it 'links containers' do - expect(cmd_executed).to match(/--link #{params[:links].to_a.flatten.join(':')} .+ #{Regexp.escape params[:image]}/) + params[:links].each do |link| + expect(cmd_executed).to match(/--link #{link.join(':')} .+ #{Regexp.escape params[:image]}/) + end end it 'sets environmental variables' do