Sha256: a01a7bb96baeab52369f8fbeeebd4212a6324bb86f0cc3642739f0efeab305c4

Contents?: true

Size: 1.78 KB

Versions: 18

Compression:

Stored size: 1.78 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 synced folders.
          invalids = {}
          fresh.each do |_, fs|
            fs.each do |_, data|
              invalid = false
              old     = existing.delete(data[:guestpath])
              if !old
                invalid = true
              else
                old = File.expand_path(old)
              end

              if !invalid && old
                invalid = true if old != File.expand_path(data[:hostpath])
              end

              if invalid
                invalids[File.expand_path(data[:guestpath])] = File.expand_path(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

18 entries across 18 versions & 3 rubygems

Version Path
vagrant-unbundled-2.3.6.0 plugins/providers/docker/action/compare_synced_folders.rb
tamtam-vagrant-reload-1.2.1 vendor/cache/vagrant-2092df529ae7/plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.3.3.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.3.2.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.2.19.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.2.18.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.2.16.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.2.14.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-aws-mkubenka-0.7.2.pre.24 vendor/bundle/ruby/2.7.0/bundler/gems/vagrant-22795b161bf6/plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.2.10.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.2.9.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.2.8.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.2.7.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.2.6.2 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.2.6.1 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.2.6.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.2.5.0 plugins/providers/docker/action/compare_synced_folders.rb
vagrant-unbundled-2.2.4.0 plugins/providers/docker/action/compare_synced_folders.rb