From 670a441a997c4e8e126412f84d8e01462a020836 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Fri, 4 Oct 2013 11:24:54 -0300 Subject: [PATCH] core: Scaffold an action for persisting box information --- lib/vagrant/action.rb | 2 ++ lib/vagrant/action/builtin/write_box_info.rb | 24 ++++++++++++++++++++ 2 files changed, 26 insertions(+) create mode 100644 lib/vagrant/action/builtin/write_box_info.rb diff --git a/lib/vagrant/action.rb b/lib/vagrant/action.rb index 52164b462..8c8a241e0 100644 --- a/lib/vagrant/action.rb +++ b/lib/vagrant/action.rb @@ -25,6 +25,7 @@ module Vagrant autoload :SSHExec, "vagrant/action/builtin/ssh_exec" autoload :SSHRun, "vagrant/action/builtin/ssh_run" autoload :WaitForCommunicator, "vagrant/action/builtin/wait_for_communicator" + autoload :WriteBoxInfo, "vagrant/action/builtin/write_box_info" end module General @@ -39,6 +40,7 @@ module Vagrant def self.action_box_add Builder.new.tap do |b| b.use Builtin::BoxAdd + b.use Builtin::WriteBoxInfo end end end diff --git a/lib/vagrant/action/builtin/write_box_info.rb b/lib/vagrant/action/builtin/write_box_info.rb new file mode 100644 index 000000000..ebf11cfb9 --- /dev/null +++ b/lib/vagrant/action/builtin/write_box_info.rb @@ -0,0 +1,24 @@ +require "log4r" + +module Vagrant + module Action + module Builtin + # This middleware will persist some extra information about the base box + class WriteBoxInfo + def initialize(app, env) + @app = app + @logger = Log4r::Logger.new("vagrant::action::builtin::write_box_info") + end + + def call(env) + box_url = env[:box_url] + box_added = env[:box_added] + + # TODO: Persist box_url / provider / datetime + + @app.call(env) + end + end + end + end +end