From 745bdf676675e7b1f25fd7df5a4ed48b582b6dc7 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Thu, 8 May 2014 18:46:03 -0700 Subject: [PATCH] providers/docker: ability to specify build dir synced folder opts [GH-3727] --- CHANGELOG.md | 2 ++ .../providers/docker/action/host_machine_build_dir.rb | 2 +- plugins/providers/docker/config.rb | 10 ++++++++++ test/unit/plugins/providers/docker/config_test.rb | 1 + website/docs/source/v2/docker/configuration.html.md | 4 ++++ 5 files changed, 18 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 26a27df25..3605f9d3c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ IMPROVEMENTS: RDP client. [GH-3686] - providers/docker: `build_args` config to specify extra args for `docker build`. [GH-3684] + - providers/docker: Can specify options for the build dir synced + folder when a host VM is in use. [GH-3727] - synced\_folders/nfs: Can tell Vagrant not to handle exporting by setting `nfs_export: false` [GH-3636] diff --git a/plugins/providers/docker/action/host_machine_build_dir.rb b/plugins/providers/docker/action/host_machine_build_dir.rb index 3b926d849..f43032631 100644 --- a/plugins/providers/docker/action/host_machine_build_dir.rb +++ b/plugins/providers/docker/action/host_machine_build_dir.rb @@ -32,7 +32,7 @@ module VagrantPlugins options = { docker__ignore: true, docker__exact: true, - } + }.merge(machine.provider_config.host_vm_build_dir_options || {}) machine.config.vm.synced_folder(build_dir, new_build_dir, options) # Set the build dir to be the correct one diff --git a/plugins/providers/docker/config.rb b/plugins/providers/docker/config.rb index f6ddedab4..139c6955e 100644 --- a/plugins/providers/docker/config.rb +++ b/plugins/providers/docker/config.rb @@ -44,6 +44,11 @@ module VagrantPlugins # provisioning, etc. attr_accessor :has_ssh + # Options for the build dir synced folder if a host VM is in use. + # + # @return [Hash] + attr_accessor :host_vm_build_dir_options + # The name for the container. This must be unique for all containers # on the proxy machine if it is made. # @@ -87,6 +92,7 @@ module VagrantPlugins @expose = [] @force_host_vm = UNSET_VALUE @has_ssh = UNSET_VALUE + @host_vm_build_dir_options = UNSET_VALUE @image = UNSET_VALUE @name = UNSET_VALUE @links = [] @@ -147,6 +153,10 @@ module VagrantPlugins @vagrant_machine = nil if @vagrant_machine == UNSET_VALUE @vagrant_vagrantfile = nil if @vagrant_vagrantfile == UNSET_VALUE + if @host_vm_build_dir_options == UNSET_VALUE + @host_vm_build_dir_options = nil + end + # The machine name must be a symbol @vagrant_machine = @vagrant_machine.to_sym if @vagrant_machine diff --git a/test/unit/plugins/providers/docker/config_test.rb b/test/unit/plugins/providers/docker/config_test.rb index 60941c326..ac20f6bc3 100644 --- a/test/unit/plugins/providers/docker/config_test.rb +++ b/test/unit/plugins/providers/docker/config_test.rb @@ -43,6 +43,7 @@ describe VagrantPlugins::DockerProvider::Config do its(:cmd) { should eq([]) } its(:env) { should eq({}) } its(:force_host_vm) { should be_false } + its(:host_vm_build_dir_options) { should be_nil } its(:image) { should be_nil } its(:name) { should be_nil } its(:privileged) { should be_false } diff --git a/website/docs/source/v2/docker/configuration.html.md b/website/docs/source/v2/docker/configuration.html.md index 6b2ca933a..e294cc7c0 100644 --- a/website/docs/source/v2/docker/configuration.html.md +++ b/website/docs/source/v2/docker/configuration.html.md @@ -44,6 +44,10 @@ you may set. A complete reference is shown below. the container. This allows `vagrant ssh` to work, provisioners, etc. This defaults to false. + * `host_vm_build_dir_options` (hash) - Synced folder options for the + `build_dir`, since the build directory is synced using a synced folder + if a host VM is in use. + * `name` (string) - Name of the container. Note that this has to be unique across all containers on the host VM. By default Vagrant will generate some random name.