From 037985320227d11047776cd40f867d602bef8756 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Sat, 23 Nov 2013 22:05:59 -0800 Subject: [PATCH] core: get rid of dependencies on @env from mixin --- lib/vagrant/action/builtin/mixin_provisioners.rb | 6 +++--- lib/vagrant/action/builtin/provision.rb | 4 ++-- lib/vagrant/action/builtin/provisioner_cleanup.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/vagrant/action/builtin/mixin_provisioners.rb b/lib/vagrant/action/builtin/mixin_provisioners.rb index ff82619ca..052a23262 100644 --- a/lib/vagrant/action/builtin/mixin_provisioners.rb +++ b/lib/vagrant/action/builtin/mixin_provisioners.rb @@ -6,17 +6,17 @@ module Vagrant # This is safe to call multiple times since it will cache the results. # # @return [Array] - def provisioner_instances + def provisioner_instances(env) return @_provisioner_instances if @_provisioner_instances # Make the mapping that'll keep track of provisioner => type @_provisioner_types = {} # Get all the configured provisioners - @_provisioner_instances = @env[:machine].config.vm.provisioners.map do |provisioner| + @_provisioner_instances = env[:machine].config.vm.provisioners.map do |provisioner| # Instantiate the provisioner klass = Vagrant.plugin("2").manager.provisioners[provisioner.name] - result = klass.new(@env[:machine], provisioner.config) + result = klass.new(env[:machine], provisioner.config) # Store in the type map so that --provision-with works properly @_provisioner_types[result] = provisioner.name diff --git a/lib/vagrant/action/builtin/provision.rb b/lib/vagrant/action/builtin/provision.rb index 7f680d344..aefd2332d 100644 --- a/lib/vagrant/action/builtin/provision.rb +++ b/lib/vagrant/action/builtin/provision.rb @@ -51,7 +51,7 @@ module Vagrant end # Ask the provisioners to modify the configuration if needed - provisioner_instances.each do |p| + provisioner_instances(env).each do |p| p.configure(env[:machine].config) end @@ -60,7 +60,7 @@ module Vagrant # Actually provision if we enabled it if enabled - provisioner_instances.each do |p| + provisioner_instances(env).each do |p| next if env[:provision_types] && \ !env[:provision_types].include?(provisioner_type_map[p]) diff --git a/lib/vagrant/action/builtin/provisioner_cleanup.rb b/lib/vagrant/action/builtin/provisioner_cleanup.rb index fed7ddc85..e9eec5c87 100644 --- a/lib/vagrant/action/builtin/provisioner_cleanup.rb +++ b/lib/vagrant/action/builtin/provisioner_cleanup.rb @@ -28,7 +28,7 @@ module Vagrant def do_cleanup(env) # Ask the provisioners to modify the configuration if needed - provisioner_instances.each do |p| + provisioner_instances(env).each do |p| env[:ui].info(I18n.t( "vagrant.provisioner_cleanup", name: provisioner_type_map[p].to_s))