Disable the plugin on machines backed by cloud providers (fix GH-45)
This commit is contained in:
parent
e0797d4e9a
commit
385da382cd
3 changed files with 20 additions and 1 deletions
|
@ -28,6 +28,12 @@ module VagrantPlugins
|
|||
def validate(machine)
|
||||
errors = _detected_errors
|
||||
|
||||
if enabled? && backed_by_cloud_provider?(machine)
|
||||
machine.ui.warn(I18n.t('vagrant_cachier.backed_by_cloud_provider',
|
||||
provider: machine.provider_name))
|
||||
disable!
|
||||
end
|
||||
|
||||
if enabled? && ! ALLOWED_SCOPES.include?(@scope.to_s)
|
||||
errors << I18n.t('vagrant_cachier.unknown_cache_scope',
|
||||
allowed: ALLOWED_SCOPES.inspect,
|
||||
|
@ -55,6 +61,12 @@ module VagrantPlugins
|
|||
@synced_folder_opts = nil if @synced_folder_opts == UNSET_VALUE
|
||||
@buckets = @buckets ? @buckets.dup : {}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def backed_by_cloud_provider?(machine)
|
||||
CLOUD_PROVIDERS.include?(machine.provider_name.to_s)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -11,12 +11,16 @@ module VagrantPlugins
|
|||
module Cachier
|
||||
class Plugin < Vagrant.plugin('2')
|
||||
name 'vagrant-cachier'
|
||||
|
||||
config 'cache' do
|
||||
require_relative "config"
|
||||
Config
|
||||
end
|
||||
end
|
||||
|
||||
# Keep an eye on https://github.com/mitchellh/vagrant/wiki/Available-Vagrant-Plugins#wiki-providers
|
||||
# for more.
|
||||
CLOUD_PROVIDERS = %w( aws cloudstack digitalocean hp joyent openstack rackspace
|
||||
softlayer proxmox managed virtualbox )
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -16,3 +16,6 @@ en:
|
|||
scoped cache dirs starting with the 0.3.0 version of the plugin.
|
||||
unable_to_ssh: |-
|
||||
vagrant-cachier was unable to SSH into the VM to remove symlinks!
|
||||
backed_by_cloud_provider: |-
|
||||
The machine is backed by a cloud provider (%{provider}), caching
|
||||
will be disabled.
|
||||
|
|
Loading…
Reference in a new issue