Disable the plugin on machines backed by cloud providers (fix GH-45)

This commit is contained in:
Fabio Rehm 2014-02-01 20:24:14 -02:00
parent 09d65c4a3c
commit 0106155a0f
3 changed files with 20 additions and 1 deletions

View file

@ -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

View file

@ -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

View file

@ -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.