Sha256: 351dd7c77f7c0a22c8ded82dabb641d5dd41c74cba6e48ebfa7e595da6d5a389

Contents?: true

Size: 1.63 KB

Versions: 32

Compression:

Stored size: 1.63 KB

Contents

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

Version data entries

32 entries across 29 versions & 6 rubygems

Version Path
vagrant-unbundled-2.0.3.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-aws-detiber-0.7.2.pre.4 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/plugins/providers/docker/action/compare_synced_folders.rb
vagrant-aws-detiber-0.7.2.pre.3 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/plugins/providers/docker/action/compare_synced_folders.rb
vagrant-aws-detiber-0.7.2.pre.2 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-419afb4dcffe/plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.0.2.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.0.1.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-aws-mkubenka-0.7.2.pre.22 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-f3fdbf414272/plugins/providers/docker/action/compare_synced_folders.rb
vagrant-aws-mkubenka-0.7.2.pre.16 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-1ee58c40e3f5/plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.0.0.1 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-1.9.8.1 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-1.9.7.1 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-aws-mkubenka-0.7.2.pre.14 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/providers/docker/action/compare_synced_folders.rb
vagrant-aws-mkubenka-0.7.2.pre.11 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/providers/docker/action/compare_synced_folders.rb
vagrant-aws-mkubenka-0.7.2.pre.10 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/providers/docker/action/compare_synced_folders.rb
vagrant-aws-mkubenka-0.7.2.pre.9 vendor/bundle/ruby/2.3.0/bundler/gems/vagrant-5333e60e2d38/plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-1.9.5.1 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-1.9.1.1 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-compose-yaml-0.1.3 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/providers/docker/action/compare_synced_folders.rb
vagrant-compose-yaml-0.1.2 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/providers/docker/action/compare_synced_folders.rb
vagrant-compose-yaml-0.1.1 vendor/bundle/ruby/2.2.0/bundler/gems/vagrant-dbb756c7b6da/plugins/providers/docker/action/compare_synced_folders.rb