[GH-6] Setting things up for making sure a single cache root exists
This commit is contained in:
parent
068d9cc8b8
commit
7ad195776d
2 changed files with 31 additions and 0 deletions
16
lib/vagrant-cachier/action/ensure_single_cache_root.rb
Normal file
16
lib/vagrant-cachier/action/ensure_single_cache_root.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
module VagrantPlugins
|
||||
module Cachier
|
||||
class Action
|
||||
class EnsureSingleCacheRoot
|
||||
def initialize(app, env)
|
||||
@app = app
|
||||
end
|
||||
|
||||
def call(env)
|
||||
raise 'Do our work'
|
||||
@app.call(env)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
|
@ -46,6 +46,21 @@ module VagrantPlugins
|
|||
Cap::Arch::PacmanCacheDir
|
||||
end
|
||||
|
||||
# TODO: This should be generic, we don't want to hard code every single
|
||||
# possible provider action class that Vagrant might have
|
||||
ensure_single_cache_root = lambda do |hook|
|
||||
require_relative 'action/ensure_single_cache_root'
|
||||
hook.after VagrantPlugins::ProviderVirtualBox::Action::Boot, Action::EnsureSingleCacheRoot
|
||||
|
||||
if defined?(Vagrant::LXC)
|
||||
# TODO: Require just the boot action file once its "require dependencies" are sorted out
|
||||
require 'vagrant-lxc/action'
|
||||
hook.after Vagrant::LXC::Action::Boot, Action::EnsureSingleCacheRoot
|
||||
end
|
||||
end
|
||||
action_hook 'ensure-single-cache-root-exists-on-up', :machine_action_up, &ensure_single_cache_root
|
||||
action_hook 'ensure-single-cache-root-exists-on-reload', :machine_action_reload, &ensure_single_cache_root
|
||||
|
||||
clean_action_hook = lambda do |hook|
|
||||
require_relative 'action/clean'
|
||||
hook.before Vagrant::Action::Builtin::GracefulHalt, VagrantPlugins::Cachier::Action::Clean
|
||||
|
|
Loading…
Reference in a new issue