providers/docker: warning if synced folders change
This commit is contained in:
parent
d1b3165545
commit
0a3346c918
|
@ -213,7 +213,6 @@ module VagrantPlugins
|
|||
b2.use HostMachineSyncFolders
|
||||
b2.use PrepareNFSValidIds
|
||||
b2.use SyncedFolderCleanup
|
||||
b2.use SyncedFolders
|
||||
b2.use PrepareNFSSettings
|
||||
|
||||
# If the VM is NOT created yet, then do some setup steps
|
||||
|
@ -221,12 +220,14 @@ module VagrantPlugins
|
|||
b2.use Call, IsState, :not_created do |env2, b3|
|
||||
if env2[:result]
|
||||
b3.use EnvSet, port_collision_repair: true
|
||||
b3.use HostMachineSyncFolders
|
||||
b3.use HostMachinePortWarning
|
||||
b3.use HostMachinePortChecker
|
||||
b3.use HandleForwardedPortCollisions
|
||||
b3.use SyncedFolders
|
||||
b3.use Create
|
||||
b3.use WaitForRunning
|
||||
else
|
||||
b3.use CompareSyncedFolders
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -244,6 +245,7 @@ module VagrantPlugins
|
|||
|
||||
# The autoload farm
|
||||
action_root = Pathname.new(File.expand_path("../action", __FILE__))
|
||||
autoload :CompareSyncedFolders, action_root.join("compare_synced_folders")
|
||||
autoload :Create, action_root.join("create")
|
||||
autoload :Destroy, action_root.join("destroy")
|
||||
autoload :HasSSH, action_root.join("has_ssh")
|
||||
|
|
|
@ -0,0 +1,58 @@
|
|||
require "vagrant/action/builtin/mixin_synced_folders"
|
||||
|
||||
module VagrantPlugins
|
||||
module DockerProvider
|
||||
module Action
|
||||
class CompareSyncedFolders
|
||||
include Vagrant::Action::Builtin::MixinSyncedFolders
|
||||
|
||||
def initialize(app, env)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
machine = env[:machine]
|
||||
|
||||
# Get the synced folders that are cached, and those that aren't
|
||||
cached = synced_folders(machine, cached: true)
|
||||
fresh = synced_folders(machine)
|
||||
|
||||
# Build up a mapping of existing setup synced folders
|
||||
existing = {}
|
||||
cached.each do |_, fs|
|
||||
fs.each do |_, data|
|
||||
existing[data[:guestpath]] = data[:hostpath]
|
||||
end
|
||||
end
|
||||
|
||||
# Remove the matching folders, and build up non-matching or
|
||||
# new syncedf olders.
|
||||
invalids = {}
|
||||
fresh.each do |_, fs|
|
||||
fs.each do |_, data|
|
||||
invalid = false
|
||||
old = existing.delete(data[:guestpath])
|
||||
invalid = true if !old
|
||||
|
||||
if !invalid && old
|
||||
invalid = true if old != data[:hostpath]
|
||||
end
|
||||
|
||||
if invalid
|
||||
invalids[data[:guestpath]] = data[:hostpath]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# If we have invalid entries, these are changed or new entries.
|
||||
# If we have existing entries, then we removed some entries.
|
||||
if !invalids.empty? || !existing.empty?
|
||||
machine.ui.warn(I18n.t("docker_provider.synced_folders_changed"))
|
||||
end
|
||||
|
||||
@app.call(env)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -32,6 +32,10 @@ en:
|
|||
ssh_through_host_vm: |-
|
||||
SSH will be proxied through the Docker virtual machine since we're
|
||||
not running Docker natively. This is just a notice, and not an error.
|
||||
synced_folders_changed: |-
|
||||
Vagrant has noticed that the synced folder definitions have changed.
|
||||
With Docker, these synced folder changes won't take effect until you
|
||||
destroy the container and recreate it.
|
||||
waiting_for_running: |-
|
||||
Waiting for container to enter "running" state...
|
||||
|
||||
|
|
Loading…
Reference in New Issue