From 89db0f64e533a502f34a79f173211b02544edfbe Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 7 May 2014 11:19:36 -0300 Subject: [PATCH 1/4] providers/docker: Rename test files for consistency --- .../plugins/providers/docker/{config_spec.rb => config_test.rb} | 0 .../plugins/providers/docker/{driver_spec.rb => driver_test.rb} | 0 .../docker/{synced_folder_spec.rb => synced_folder_test.rb} | 0 3 files changed, 0 insertions(+), 0 deletions(-) rename test/unit/plugins/providers/docker/{config_spec.rb => config_test.rb} (100%) rename test/unit/plugins/providers/docker/{driver_spec.rb => driver_test.rb} (100%) rename test/unit/plugins/providers/docker/{synced_folder_spec.rb => synced_folder_test.rb} (100%) diff --git a/test/unit/plugins/providers/docker/config_spec.rb b/test/unit/plugins/providers/docker/config_test.rb similarity index 100% rename from test/unit/plugins/providers/docker/config_spec.rb rename to test/unit/plugins/providers/docker/config_test.rb diff --git a/test/unit/plugins/providers/docker/driver_spec.rb b/test/unit/plugins/providers/docker/driver_test.rb similarity index 100% rename from test/unit/plugins/providers/docker/driver_spec.rb rename to test/unit/plugins/providers/docker/driver_test.rb diff --git a/test/unit/plugins/providers/docker/synced_folder_spec.rb b/test/unit/plugins/providers/docker/synced_folder_test.rb similarity index 100% rename from test/unit/plugins/providers/docker/synced_folder_spec.rb rename to test/unit/plugins/providers/docker/synced_folder_test.rb From b68cb6d7b408a494dccb96383b20387de7db0339 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 7 May 2014 12:07:53 -0300 Subject: [PATCH 2/4] providers/docker: Container links are an array, not a hash --- plugins/providers/docker/driver.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/providers/docker/driver.rb b/plugins/providers/docker/driver.rb index 35e8b73b8..37d109d9b 100644 --- a/plugins/providers/docker/driver.rb +++ b/plugins/providers/docker/driver.rb @@ -29,7 +29,7 @@ module VagrantPlugins def create(params, **opts, &block) image = params.fetch(:image) - links = params.fetch(:links) + links = Array(params.fetch(:links)) ports = Array(params[:ports]) volumes = Array(params[:volumes]) name = params.fetch(:name) @@ -41,7 +41,7 @@ module VagrantPlugins run_cmd << "-d" if params[:detach] run_cmd += env.map { |k,v| ['-e', "#{k}=#{v}"] } run_cmd += expose.map { |p| ['--expose', "#{p}"] } - run_cmd += links.map { |k, v| ['--link', "#{k}:#{v}"] } + run_cmd += links.map { |l| ['--link', "#{l}"] } run_cmd += ports.map { |p| ['-p', p.to_s] } run_cmd += volumes.map { |v| ['-v', v.to_s] } run_cmd += %W(--privileged) if params[:privileged] From 3ab5064e021bb3ab482b8449228cbda17964dec8 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 7 May 2014 12:09:48 -0300 Subject: [PATCH 3/4] providers/docker: Add required configs and specs (build is green now) --- test/unit/plugins/providers/docker/driver_test.rb | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/unit/plugins/providers/docker/driver_test.rb b/test/unit/plugins/providers/docker/driver_test.rb index c41bb3924..e5994a7bf 100644 --- a/test/unit/plugins/providers/docker/driver_test.rb +++ b/test/unit/plugins/providers/docker/driver_test.rb @@ -16,6 +16,9 @@ describe VagrantPlugins::DockerProvider::Driver do cmd: ['play', 'voodoo-chile'], ports: '8080:80', volumes: '/host/path:guest/path', + detach: true, + links: 'janis:joplin', + env: {key: 'value'}, name: cid, hostname: 'jimi-hendrix', privileged: true @@ -39,6 +42,14 @@ describe VagrantPlugins::DockerProvider::Driver do expect(cmd_executed).to match(/-v #{params[:volumes]} .+ #{Regexp.escape params[:image]}/) end + it 'links containers' do + expect(cmd_executed).to match(/--link #{params[:links]} .+ #{Regexp.escape params[:image]}/) + end + + it 'sets environmental variables' do + expect(cmd_executed).to match(/-e key=value .+ #{Regexp.escape params[:image]}/) + end + it 'is able to run a privileged container' do expect(cmd_executed).to match(/-privileged .+ #{Regexp.escape params[:image]}/) end From 7538d07233a191ae0ea2042c23b2c5b72215344e Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 7 May 2014 12:10:32 -0300 Subject: [PATCH 4/4] providers/docker: Ensure long flags are used --- test/unit/plugins/providers/docker/driver_test.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/unit/plugins/providers/docker/driver_test.rb b/test/unit/plugins/providers/docker/driver_test.rb index e5994a7bf..17ee06609 100644 --- a/test/unit/plugins/providers/docker/driver_test.rb +++ b/test/unit/plugins/providers/docker/driver_test.rb @@ -31,7 +31,7 @@ describe VagrantPlugins::DockerProvider::Driver do end it 'sets container name' do - expect(cmd_executed).to match(/-name #{Regexp.escape params[:name]}/) + expect(cmd_executed).to match(/--name #{Regexp.escape params[:name]}/) end it 'forwards ports' do @@ -51,7 +51,7 @@ describe VagrantPlugins::DockerProvider::Driver do end it 'is able to run a privileged container' do - expect(cmd_executed).to match(/-privileged .+ #{Regexp.escape params[:image]}/) + expect(cmd_executed).to match(/--privileged .+ #{Regexp.escape params[:image]}/) end it 'sets the hostname if specified' do