vagrant-cachier 0.5.1 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +33 -0
- data/Gemfile +1 -1
- data/Gemfile.lock +59 -34
- data/LICENSE.txt +1 -1
- data/README.md +27 -10
- data/development/Cheffile.lock +1 -5
- data/development/Vagrantfile +81 -71
- data/docs/buckets/apt-lists.md +18 -0
- data/docs/how-does-it-work.md +5 -6
- data/docs/index.md +24 -5
- data/docs/template.html +1 -0
- data/docs/usage.md +81 -28
- data/lib/vagrant-cachier/action/clean.rb +1 -1
- data/lib/vagrant-cachier/action/configure_bucket_root.rb +46 -0
- data/lib/vagrant-cachier/action/install_buckets.rb +47 -0
- data/lib/vagrant-cachier/bucket.rb +55 -0
- data/lib/vagrant-cachier/bucket/apt.rb +3 -12
- data/lib/vagrant-cachier/bucket/apt_cacher.rb +1 -13
- data/lib/vagrant-cachier/bucket/apt_lists.rb +24 -0
- data/lib/vagrant-cachier/bucket/chef.rb +1 -14
- data/lib/vagrant-cachier/bucket/composer.rb +1 -14
- data/lib/vagrant-cachier/bucket/gem.rb +4 -17
- data/lib/vagrant-cachier/bucket/npm.rb +1 -14
- data/lib/vagrant-cachier/bucket/pacman.rb +1 -14
- data/lib/vagrant-cachier/bucket/rvm.rb +4 -17
- data/lib/vagrant-cachier/bucket/yum.rb +4 -15
- data/lib/vagrant-cachier/bucket/zypper.rb +4 -15
- data/lib/vagrant-cachier/cap/debian/apt_lists_dir.rb +13 -0
- data/lib/vagrant-cachier/capabilities.rb +64 -0
- data/lib/vagrant-cachier/config.rb +35 -10
- data/lib/vagrant-cachier/hooks.rb +27 -0
- data/lib/vagrant-cachier/plugin.rb +12 -80
- data/lib/vagrant-cachier/version.rb +1 -1
- data/locales/en.yml +3 -7
- data/vagrant-cachier.gemspec +11 -1
- metadata +20 -12
- data/lib/vagrant-cachier/action/ensure_single_cache_root.rb +0 -64
- data/lib/vagrant-cachier/errors.rb +0 -9
- data/lib/vagrant-cachier/provision_ext.rb +0 -74
| @@ -9,22 +9,10 @@ module VagrantPlugins | |
| 9 9 | 
             
                    end
         | 
| 10 10 |  | 
| 11 11 | 
             
                    def install
         | 
| 12 | 
            -
                      machine = @env[:machine]
         | 
| 13 | 
            -
                      guest   = machine.guest
         | 
| 14 | 
            -
             | 
| 15 12 | 
             
                      if guest.capability?(:apt_cacher_dir)
         | 
| 16 13 | 
             
                        if guest_path = guest.capability(:apt_cacher_dir)
         | 
| 17 14 | 
             
                          if machine.config.cache.enable_nfs
         | 
| 18 | 
            -
                             | 
| 19 | 
            -
             | 
| 20 | 
            -
                            machine.communicate.tap do |comm|
         | 
| 21 | 
            -
                              comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}")
         | 
| 22 | 
            -
                              unless comm.test("test -L #{guest_path}")
         | 
| 23 | 
            -
                                comm.sudo("rm -rf #{guest_path}")
         | 
| 24 | 
            -
                                comm.sudo("mkdir -p `dirname #{guest_path}`")
         | 
| 25 | 
            -
                                comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
         | 
| 26 | 
            -
                              end
         | 
| 27 | 
            -
                            end
         | 
| 15 | 
            +
                            symlink(guest_path)
         | 
| 28 16 | 
             
                          else
         | 
| 29 17 | 
             
                            @env[:ui].info I18n.t('vagrant_cachier.nfs_required', bucket: 'apt-cacher')
         | 
| 30 18 | 
             
                          end
         | 
| @@ -0,0 +1,24 @@ | |
| 1 | 
            +
            module VagrantPlugins
         | 
| 2 | 
            +
              module Cachier
         | 
| 3 | 
            +
                class Bucket
         | 
| 4 | 
            +
                  class AptLists < Bucket
         | 
| 5 | 
            +
                    def self.capability
         | 
| 6 | 
            +
                      :apt_lists_dir
         | 
| 7 | 
            +
                    end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                    def install
         | 
| 10 | 
            +
                      if guest.capability?(:apt_lists_dir)
         | 
| 11 | 
            +
                        guest_path = guest.capability(:apt_lists_dir)
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                        return if @env[:cache_dirs].include?(guest_path)
         | 
| 14 | 
            +
             | 
| 15 | 
            +
                        symlink(guest_path)
         | 
| 16 | 
            +
                        comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}/partial")
         | 
| 17 | 
            +
                      else
         | 
| 18 | 
            +
                        @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'apt-lists')
         | 
| 19 | 
            +
                      end
         | 
| 20 | 
            +
                    end
         | 
| 21 | 
            +
                  end
         | 
| 22 | 
            +
                end
         | 
| 23 | 
            +
              end
         | 
| 24 | 
            +
            end
         | 
| @@ -7,22 +7,9 @@ module VagrantPlugins | |
| 7 7 | 
             
                    end
         | 
| 8 8 |  | 
| 9 9 | 
             
                    def install
         | 
| 10 | 
            -
                      machine = @env[:machine]
         | 
| 11 | 
            -
                      guest   = machine.guest
         | 
| 12 | 
            -
             | 
| 13 10 | 
             
                      if guest.capability?(:chef_file_cache_path)
         | 
| 14 11 | 
             
                        guest_path = guest.capability(:chef_file_cache_path)
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                        @env[:cache_dirs] << guest_path
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                        machine.communicate.tap do |comm|
         | 
| 19 | 
            -
                          comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}")
         | 
| 20 | 
            -
                          unless comm.test("test -L #{guest_path}")
         | 
| 21 | 
            -
                            comm.sudo("rm -rf #{guest_path}")
         | 
| 22 | 
            -
                            comm.sudo("mkdir -p `dirname #{guest_path}`")
         | 
| 23 | 
            -
                            comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
         | 
| 24 | 
            -
                          end
         | 
| 25 | 
            -
                        end
         | 
| 12 | 
            +
                        symlink(guest_path) if guest_path
         | 
| 26 13 | 
             
                      else
         | 
| 27 14 | 
             
                        @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Chef')
         | 
| 28 15 | 
             
                      end
         | 
| @@ -7,22 +7,9 @@ module VagrantPlugins | |
| 7 7 | 
             
                    end
         | 
| 8 8 |  | 
| 9 9 | 
             
                    def install
         | 
| 10 | 
            -
                      machine = @env[:machine]
         | 
| 11 | 
            -
                      guest   = machine.guest
         | 
| 12 | 
            -
             | 
| 13 10 | 
             
                      if guest.capability?(:composer_path)
         | 
| 14 11 | 
             
                        if composer_path = guest.capability(:composer_path)
         | 
| 15 | 
            -
                           | 
| 16 | 
            -
                          @env[:cache_dirs] << composer_path
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                          machine.communicate.tap do |comm|
         | 
| 19 | 
            -
                            comm.execute("mkdir -p #{bucket_path}")
         | 
| 20 | 
            -
             | 
| 21 | 
            -
                            unless comm.test("test -L #{composer_path}")
         | 
| 22 | 
            -
                              comm.sudo("rm -rf #{composer_path}")
         | 
| 23 | 
            -
                              comm.sudo("ln -s #{bucket_path} #{composer_path}")
         | 
| 24 | 
            -
                           end
         | 
| 25 | 
            -
                          end
         | 
| 12 | 
            +
                          symlink(composer_path, create_parent: false)
         | 
| 26 13 | 
             
                        end
         | 
| 27 14 | 
             
                      else
         | 
| 28 15 | 
             
                        @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Composer')
         | 
| @@ -7,26 +7,13 @@ module VagrantPlugins | |
| 7 7 | 
             
                    end
         | 
| 8 8 |  | 
| 9 9 | 
             
                    def install
         | 
| 10 | 
            -
                      machine = @env[:machine]
         | 
| 11 | 
            -
                      guest   = machine.guest
         | 
| 12 | 
            -
             | 
| 13 10 | 
             
                      if guest.capability?(:gemdir)
         | 
| 14 11 | 
             
                        if gemdir_path = guest.capability(:gemdir)
         | 
| 15 | 
            -
                          prefix | 
| 16 | 
            -
                          bucket_path | 
| 17 | 
            -
                           | 
| 18 | 
            -
                            comm.execute("mkdir -p #{bucket_path}")
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                            gem_cache_path = "#{gemdir_path}/cache"
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                            @env[:cache_dirs] << gem_cache_path
         | 
| 12 | 
            +
                          prefix         = gemdir_path.split('/').last
         | 
| 13 | 
            +
                          bucket_path    = "/tmp/vagrant-cache/#{@name}/#{prefix}"
         | 
| 14 | 
            +
                          gem_cache_path = "#{gemdir_path}/cache"
         | 
| 23 15 |  | 
| 24 | 
            -
             | 
| 25 | 
            -
                              comm.sudo("rm -rf #{gem_cache_path}")
         | 
| 26 | 
            -
                              comm.sudo("mkdir -p `dirname #{gem_cache_path}`")
         | 
| 27 | 
            -
                              comm.sudo("ln -s #{bucket_path} #{gem_cache_path}")
         | 
| 28 | 
            -
                            end
         | 
| 29 | 
            -
                          end
         | 
| 16 | 
            +
                          symlink(gem_cache_path, bucket_path)
         | 
| 30 17 | 
             
                        end
         | 
| 31 18 | 
             
                      else
         | 
| 32 19 | 
             
                        @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'RubyGems')
         | 
| @@ -7,22 +7,9 @@ module VagrantPlugins | |
| 7 7 | 
             
                    end
         | 
| 8 8 |  | 
| 9 9 | 
             
                    def install
         | 
| 10 | 
            -
                      machine = @env[:machine]
         | 
| 11 | 
            -
                      guest   = machine.guest
         | 
| 12 | 
            -
             | 
| 13 10 | 
             
                      if guest.capability?(:npm_cache_dir)
         | 
| 14 11 | 
             
                        guest_path = guest.capability(:npm_cache_dir)
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                        @env[:cache_dirs] << guest_path
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                        machine.communicate.tap do |comm|
         | 
| 19 | 
            -
                          comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}")
         | 
| 20 | 
            -
                          unless comm.test("test -L #{guest_path}")
         | 
| 21 | 
            -
                            comm.execute("rm -rf #{guest_path}")
         | 
| 22 | 
            -
                            comm.execute("mkdir -p `dirname #{guest_path}`")
         | 
| 23 | 
            -
                            comm.execute("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
         | 
| 24 | 
            -
                          end
         | 
| 25 | 
            -
                        end
         | 
| 12 | 
            +
                        user_symlink(guest_path) if guest_path
         | 
| 26 13 | 
             
                      else
         | 
| 27 14 | 
             
                        @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'npm')
         | 
| 28 15 | 
             
                      end
         | 
| @@ -7,22 +7,9 @@ module VagrantPlugins | |
| 7 7 | 
             
                    end
         | 
| 8 8 |  | 
| 9 9 | 
             
                    def install
         | 
| 10 | 
            -
                      machine = @env[:machine]
         | 
| 11 | 
            -
                      guest   = machine.guest
         | 
| 12 | 
            -
             | 
| 13 10 | 
             
                      if guest.capability?(:pacman_cache_dir)
         | 
| 14 11 | 
             
                        guest_path = guest.capability(:pacman_cache_dir)
         | 
| 15 | 
            -
             | 
| 16 | 
            -
                        @env[:cache_dirs] << guest_path
         | 
| 17 | 
            -
             | 
| 18 | 
            -
                        machine.communicate.tap do |comm|
         | 
| 19 | 
            -
                          comm.execute("mkdir -p /tmp/vagrant-cache/#{@name}")
         | 
| 20 | 
            -
                          unless comm.test("test -L #{guest_path}")
         | 
| 21 | 
            -
                            comm.sudo("rm -rf #{guest_path}")
         | 
| 22 | 
            -
                            comm.sudo("mkdir -p `dirname #{guest_path}`")
         | 
| 23 | 
            -
                            comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
         | 
| 24 | 
            -
                          end
         | 
| 25 | 
            -
                        end
         | 
| 12 | 
            +
                        symlink(guest_path)
         | 
| 26 13 | 
             
                      else
         | 
| 27 14 | 
             
                        @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Pacman')
         | 
| 28 15 | 
             
                      end
         | 
| @@ -7,26 +7,13 @@ module VagrantPlugins | |
| 7 7 | 
             
                    end
         | 
| 8 8 |  | 
| 9 9 | 
             
                    def install
         | 
| 10 | 
            -
                      machine = @env[:machine]
         | 
| 11 | 
            -
                      guest   = machine.guest
         | 
| 12 | 
            -
             | 
| 13 10 | 
             
                      if guest.capability?(:rvm_path)
         | 
| 14 11 | 
             
                        if rvm_path = guest.capability(:rvm_path)
         | 
| 15 | 
            -
                          prefix | 
| 16 | 
            -
                          bucket_path | 
| 17 | 
            -
                           | 
| 18 | 
            -
                            comm.execute("mkdir -p #{bucket_path}")
         | 
| 19 | 
            -
             | 
| 20 | 
            -
                            rvm_cache_path = "#{rvm_path}/archives"
         | 
| 21 | 
            -
             | 
| 22 | 
            -
                            @env[:cache_dirs] << rvm_cache_path
         | 
| 12 | 
            +
                          prefix         = rvm_path.split('/').last
         | 
| 13 | 
            +
                          bucket_path    = "/tmp/vagrant-cache/#{@name}/#{prefix}"
         | 
| 14 | 
            +
                          rvm_cache_path = "#{rvm_path}/archives"
         | 
| 23 15 |  | 
| 24 | 
            -
             | 
| 25 | 
            -
                              comm.sudo("rm -rf #{rvm_cache_path}")
         | 
| 26 | 
            -
                              comm.sudo("mkdir -p `dirname #{rvm_cache_path}`")
         | 
| 27 | 
            -
                              comm.sudo("ln -s #{bucket_path} #{rvm_cache_path}")
         | 
| 28 | 
            -
                            end
         | 
| 29 | 
            -
                          end
         | 
| 16 | 
            +
                          symlink(rvm_cache_path, bucket_path)
         | 
| 30 17 | 
             
                        end
         | 
| 31 18 | 
             
                      else
         | 
| 32 19 | 
             
                        @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'RVM')
         | 
| @@ -7,25 +7,14 @@ module VagrantPlugins | |
| 7 7 | 
             
                    end
         | 
| 8 8 |  | 
| 9 9 | 
             
                    def install
         | 
| 10 | 
            -
                      machine = @env[:machine]
         | 
| 11 | 
            -
                      guest   = machine.guest
         | 
| 12 | 
            -
             | 
| 13 10 | 
             
                      if guest.capability?(:yum_cache_dir)
         | 
| 14 11 | 
             
                        guest_path = guest.capability(:yum_cache_dir)
         | 
| 12 | 
            +
                        return if @env[:cache_dirs].include?(guest_path)
         | 
| 15 13 |  | 
| 16 | 
            -
                         | 
| 17 | 
            -
             | 
| 18 | 
            -
                        machine.communicate.tap do |comm|
         | 
| 19 | 
            -
                          # Ensure caching is enabled
         | 
| 20 | 
            -
                          comm.sudo("sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf")
         | 
| 14 | 
            +
                        # Ensure caching is enabled
         | 
| 15 | 
            +
                        comm.sudo("sed -i 's/keepcache=0/keepcache=1/g' /etc/yum.conf")
         | 
| 21 16 |  | 
| 22 | 
            -
             | 
| 23 | 
            -
                          unless comm.test("test -L #{guest_path}")
         | 
| 24 | 
            -
                            comm.sudo("rm -rf #{guest_path}")
         | 
| 25 | 
            -
                            comm.sudo("mkdir -p `dirname #{guest_path}`")
         | 
| 26 | 
            -
                            comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
         | 
| 27 | 
            -
                          end
         | 
| 28 | 
            -
                        end
         | 
| 17 | 
            +
                        symlink(guest_path)
         | 
| 29 18 | 
             
                      else
         | 
| 30 19 | 
             
                        @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Yum')
         | 
| 31 20 | 
             
                      end
         | 
| @@ -7,25 +7,14 @@ module VagrantPlugins | |
| 7 7 | 
             
                    end
         | 
| 8 8 |  | 
| 9 9 | 
             
                    def install
         | 
| 10 | 
            -
                      machine = @env[:machine]
         | 
| 11 | 
            -
                      guest   = machine.guest
         | 
| 12 | 
            -
             | 
| 13 10 | 
             
                      if guest.capability?(:zypper_cache_dir)
         | 
| 14 11 | 
             
                        guest_path = guest.capability(:zypper_cache_dir)
         | 
| 12 | 
            +
                        return if @env[:cache_dirs].include?(guest_path)
         | 
| 15 13 |  | 
| 16 | 
            -
                         | 
| 17 | 
            -
             | 
| 18 | 
            -
                        machine.communicate.tap do |comm|
         | 
| 19 | 
            -
                          # Ensure caching is enabled
         | 
| 20 | 
            -
                          comm.sudo("zypper modifyrepo --keep-packages --all")
         | 
| 14 | 
            +
                        # Ensure caching is enabled
         | 
| 15 | 
            +
                        comm.sudo("zypper modifyrepo --keep-packages --all")
         | 
| 21 16 |  | 
| 22 | 
            -
             | 
| 23 | 
            -
                          unless comm.test("test -L #{guest_path}")
         | 
| 24 | 
            -
                            comm.sudo("rm -rf #{guest_path}")
         | 
| 25 | 
            -
                            comm.sudo("mkdir -p `dirname #{guest_path}`")
         | 
| 26 | 
            -
                            comm.sudo("ln -s /tmp/vagrant-cache/#{@name} #{guest_path}")
         | 
| 27 | 
            -
                          end
         | 
| 28 | 
            -
                        end
         | 
| 17 | 
            +
                        symlink(guest_path)
         | 
| 29 18 | 
             
                      else
         | 
| 30 19 | 
             
                        @env[:ui].info I18n.t('vagrant_cachier.skipping_bucket', bucket: 'Zypper')
         | 
| 31 20 | 
             
                      end
         | 
| @@ -0,0 +1,64 @@ | |
| 1 | 
            +
            module VagrantPlugins
         | 
| 2 | 
            +
              module Cachier
         | 
| 3 | 
            +
                class Plugin < Vagrant.plugin('2')
         | 
| 4 | 
            +
                  guest_capability 'linux', 'gemdir' do
         | 
| 5 | 
            +
                    require_relative 'cap/linux/gemdir'
         | 
| 6 | 
            +
                    Cap::Linux::Gemdir
         | 
| 7 | 
            +
                  end
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                  guest_capability 'linux', 'rvm_path' do
         | 
| 10 | 
            +
                    require_relative 'cap/linux/rvm_path'
         | 
| 11 | 
            +
                    Cap::Linux::RvmPath
         | 
| 12 | 
            +
                  end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                  guest_capability 'linux', 'composer_path' do
         | 
| 15 | 
            +
                    require_relative 'cap/linux/composer_path'
         | 
| 16 | 
            +
                    Cap::Linux::ComposerPath
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  guest_capability 'linux', 'chef_file_cache_path' do
         | 
| 20 | 
            +
                    require_relative 'cap/linux/chef_file_cache_path'
         | 
| 21 | 
            +
                    Cap::Linux::ChefFileCachePath
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
             | 
| 24 | 
            +
                  guest_capability 'linux', 'npm_cache_dir' do
         | 
| 25 | 
            +
                    require_relative 'cap/linux/npm_cache_dir'
         | 
| 26 | 
            +
                    Cap::Linux::NpmCacheDir
         | 
| 27 | 
            +
                  end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
                  guest_capability 'debian', 'apt_cache_dir' do
         | 
| 30 | 
            +
                    require_relative 'cap/debian/apt_cache_dir'
         | 
| 31 | 
            +
                    Cap::Debian::AptCacheDir
         | 
| 32 | 
            +
                  end
         | 
| 33 | 
            +
             | 
| 34 | 
            +
                  guest_capability 'debian', 'apt_cacher_dir' do
         | 
| 35 | 
            +
                    require_relative 'cap/debian/apt_cacher_dir'
         | 
| 36 | 
            +
                    Cap::Debian::AptCacherDir
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  guest_capability 'debian', 'apt_lists_dir' do
         | 
| 40 | 
            +
                    require_relative 'cap/debian/apt_lists_dir'
         | 
| 41 | 
            +
                    Cap::Debian::AptListsDir
         | 
| 42 | 
            +
                  end
         | 
| 43 | 
            +
             | 
| 44 | 
            +
                  guest_capability 'redhat', 'yum_cache_dir' do
         | 
| 45 | 
            +
                    require_relative 'cap/redhat/yum_cache_dir'
         | 
| 46 | 
            +
                    Cap::RedHat::YumCacheDir
         | 
| 47 | 
            +
                  end
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                  guest_capability 'suse', 'yum_cache_dir' do
         | 
| 50 | 
            +
                    # Disable Yum on suse guests
         | 
| 51 | 
            +
                  end
         | 
| 52 | 
            +
             | 
| 53 | 
            +
                  guest_capability 'arch', 'pacman_cache_dir' do
         | 
| 54 | 
            +
                    require_relative 'cap/arch/pacman_cache_dir'
         | 
| 55 | 
            +
                    Cap::Arch::PacmanCacheDir
         | 
| 56 | 
            +
                  end
         | 
| 57 | 
            +
             | 
| 58 | 
            +
                  guest_capability 'suse', 'zypper_cache_dir' do
         | 
| 59 | 
            +
                    require_relative 'cap/suse/zypper_cache_dir'
         | 
| 60 | 
            +
                    Cap::SuSE::ZypperCacheDir
         | 
| 61 | 
            +
                  end
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
              end
         | 
| 64 | 
            +
            end
         | 
| @@ -1,24 +1,39 @@ | |
| 1 1 | 
             
            module VagrantPlugins
         | 
| 2 2 | 
             
              module Cachier
         | 
| 3 3 | 
             
                class Config < Vagrant.plugin(2, :config)
         | 
| 4 | 
            -
                  attr_accessor :scope, :auto_detect, : | 
| 4 | 
            +
                  attr_accessor :scope, :auto_detect, :synced_folder_opts
         | 
| 5 5 | 
             
                  attr_reader   :buckets
         | 
| 6 6 |  | 
| 7 7 | 
             
                  ALLOWED_SCOPES = %w( box machine )
         | 
| 8 8 |  | 
| 9 9 | 
             
                  def initialize
         | 
| 10 | 
            -
                    @scope | 
| 10 | 
            +
                    @scope = UNSET_VALUE
         | 
| 11 11 | 
             
                    @auto_detect = UNSET_VALUE
         | 
| 12 | 
            -
                    @ | 
| 12 | 
            +
                    @synced_folder_opts = UNSET_VALUE
         | 
| 13 | 
            +
                    @ui = Vagrant::UI::Colored.new
         | 
| 13 14 | 
             
                  end
         | 
| 14 15 |  | 
| 15 16 | 
             
                  def enable(bucket, opts = {})
         | 
| 16 17 | 
             
                    (@buckets ||= {})[bucket] = opts
         | 
| 17 18 | 
             
                  end
         | 
| 18 19 |  | 
| 20 | 
            +
                  def enable_nfs=(value)
         | 
| 21 | 
            +
                    @ui.warn "The `enable_nfs` config for vagrant-cachier has been deprecated " \
         | 
| 22 | 
            +
                            "and will be removed on 0.7.0, please use " \
         | 
| 23 | 
            +
                            "`synced_folder_opts = { type: :nfs }` instead.\n"
         | 
| 24 | 
            +
             | 
| 25 | 
            +
                    @synced_folder_opts = { type: :nfs } if value
         | 
| 26 | 
            +
                  end
         | 
| 27 | 
            +
             | 
| 19 28 | 
             
                  def validate(machine)
         | 
| 20 29 | 
             
                    errors = _detected_errors
         | 
| 21 30 |  | 
| 31 | 
            +
                    if enabled? && backed_by_cloud_provider?(machine)
         | 
| 32 | 
            +
                      machine.ui.warn(I18n.t('vagrant_cachier.backed_by_cloud_provider',
         | 
| 33 | 
            +
                                             provider: machine.provider_name))
         | 
| 34 | 
            +
                      disable!
         | 
| 35 | 
            +
                    end
         | 
| 36 | 
            +
             | 
| 22 37 | 
             
                    if enabled? && ! ALLOWED_SCOPES.include?(@scope.to_s)
         | 
| 23 38 | 
             
                      errors << I18n.t('vagrant_cachier.unknown_cache_scope',
         | 
| 24 39 | 
             
                                        allowed:     ALLOWED_SCOPES.inspect,
         | 
| @@ -28,18 +43,28 @@ module VagrantPlugins | |
| 28 43 | 
             
                    { "vagrant cachier" => errors }
         | 
| 29 44 | 
             
                  end
         | 
| 30 45 |  | 
| 46 | 
            +
                  def enabled?
         | 
| 47 | 
            +
                    return @enabled unless @enabled.nil?
         | 
| 48 | 
            +
             | 
| 49 | 
            +
                    @enabled = @scope != UNSET_VALUE
         | 
| 50 | 
            +
                  end
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  def disable!
         | 
| 53 | 
            +
                    @enabled = false
         | 
| 54 | 
            +
                  end
         | 
| 55 | 
            +
             | 
| 31 56 | 
             
                  def finalize!
         | 
| 32 57 | 
             
                    return unless enabled?
         | 
| 33 58 |  | 
| 34 | 
            -
                    @ | 
| 35 | 
            -
                    @ | 
| 36 | 
            -
                    @ | 
| 37 | 
            -
                    @buckets     = @buckets ? @buckets.dup : {}
         | 
| 59 | 
            +
                    @auto_detect = true if @auto_detect == UNSET_VALUE
         | 
| 60 | 
            +
                    @synced_folder_opts = nil if @synced_folder_opts == UNSET_VALUE
         | 
| 61 | 
            +
                    @buckets = @buckets ? @buckets.dup : {}
         | 
| 38 62 | 
             
                  end
         | 
| 39 63 |  | 
| 40 | 
            -
                   | 
| 41 | 
            -
             | 
| 42 | 
            -
             | 
| 64 | 
            +
                  private
         | 
| 65 | 
            +
             | 
| 66 | 
            +
                  def backed_by_cloud_provider?(machine)
         | 
| 67 | 
            +
                    CLOUD_PROVIDERS.include?(machine.provider_name.to_s)
         | 
| 43 68 | 
             
                  end
         | 
| 44 69 | 
             
                end
         | 
| 45 70 | 
             
              end
         | 
| @@ -0,0 +1,27 @@ | |
| 1 | 
            +
            module VagrantPlugins
         | 
| 2 | 
            +
              module Cachier
         | 
| 3 | 
            +
                class Plugin < Vagrant.plugin('2')
         | 
| 4 | 
            +
                  action_hook VagrantPlugins::Cachier::Plugin::ALL_ACTIONS do |hook|
         | 
| 5 | 
            +
                    require_relative 'action/configure_bucket_root'
         | 
| 6 | 
            +
                    require_relative 'action/install_buckets'
         | 
| 7 | 
            +
             | 
| 8 | 
            +
                    hook.before Vagrant::Action::Builtin::Provision, Action::ConfigureBucketRoot
         | 
| 9 | 
            +
                    # This will do the initial buckets installation
         | 
| 10 | 
            +
                    hook.after Vagrant::Action::Builtin::Provision, Action::InstallBuckets, chmod: true
         | 
| 11 | 
            +
                  end
         | 
| 12 | 
            +
             | 
| 13 | 
            +
                  # This ensure buckets are reconfigured after provisioners runs
         | 
| 14 | 
            +
                  action_hook :provisioner_run do |hook|
         | 
| 15 | 
            +
                    require_relative 'action/install_buckets'
         | 
| 16 | 
            +
                    hook.after :run_provisioner, Action::InstallBuckets
         | 
| 17 | 
            +
                  end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
                  clean_action_hook = lambda do |hook|
         | 
| 20 | 
            +
                    require_relative 'action/clean'
         | 
| 21 | 
            +
                    hook.before Vagrant::Action::Builtin::GracefulHalt, Action::Clean
         | 
| 22 | 
            +
                  end
         | 
| 23 | 
            +
                  action_hook 'remove-guest-symlinks-on-halt',    :machine_action_halt,    &clean_action_hook
         | 
| 24 | 
            +
                  action_hook 'remove-guest-symlinks-on-package', :machine_action_package, &clean_action_hook
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
              end
         | 
| 27 | 
            +
            end
         |