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.
5 6 7 |
# File 'lib/vagrant-saltdeps/action.rb', line 5 def initialize(app, env) @app = app end |
Instance Method Details
#call(env) ⇒ Object
9 10 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 |
# File 'lib/vagrant-saltdeps/action.rb', line 9 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 Errors::GitCheckoutError :branch => branch, :message => e. 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 |