Class: Vagrant::Saltdeps::Action
- Inherits:
-
Object
- Object
- Vagrant::Saltdeps::Action
- Defined in:
- lib/vagrant-saltdeps/action.rb
Instance Method Summary collapse
- #call(env) ⇒ Object
-
#initialize(app, env) ⇒ Action
constructor
A new instance of Action.
Constructor Details
#initialize(app, env) ⇒ Action
Returns a new instance of Action.
7 8 9 |
# File 'lib/vagrant-saltdeps/action.rb', line 7 def initialize(app, env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/vagrant-saltdeps/action.rb', line 11 def call(env) base_vagrantfile = Vagrant::Plugin::V2::Config.const_get(:UNSET_VALUE) checkout_path = Vagrant::Plugin::V2::Config.const_get(:UNSET_VALUE) config_loader = env[:env].config_loader v = Vagrantfile.new(config_loader, [:home,:root]) v.config.vm.provisioners.each do |provisioner| if provisioner.config.class.to_s == 'VagrantPlugins::Saltdeps::Config::Provisioner' base_vagrantfile = provisioner.config.base_vagrantfile checkout_path = provisioner.config.checkout_path end end if base_vagrantfile != Vagrant::Plugin::V2::Config.const_get(:UNSET_VALUE) uri = base_vagrantfile name = "base-vagrantfile" branch = 'master' if File.directory? checkout_path + "/#{name}" g = Git.open checkout_path + "/#{name}" else g = Git.clone(uri, name, path: checkout_path) end begin g.checkout(branch) g.pull rescue Git::GitExecuteError => e raise Vagrant::Errors::VagrantError :branch => branch, :message => e. #raise VagrantPlugins::SaltErrors::GitCheckoutError :branch => branch, :message => e.message end config_loader.set(:base_vagrantfile, "#{checkout_path}/#{name}/Vagrantfile") env[:env].instance_variable_set(:@vagrantfile, Vagrantfile.new(config_loader, [:home, :base_vagrantfile, :root])) end end |