core: get rid of dependencies on @env from mixin

This commit is contained in:
Mitchell Hashimoto 2013-11-23 22:05:59 -08:00
parent f0f8b4e3ee
commit 0379853202
3 changed files with 6 additions and 6 deletions

View File

@ -6,17 +6,17 @@ module Vagrant
# This is safe to call multiple times since it will cache the results. # This is safe to call multiple times since it will cache the results.
# #
# @return [Array<Provisioner>] # @return [Array<Provisioner>]
def provisioner_instances def provisioner_instances(env)
return @_provisioner_instances if @_provisioner_instances return @_provisioner_instances if @_provisioner_instances
# Make the mapping that'll keep track of provisioner => type # Make the mapping that'll keep track of provisioner => type
@_provisioner_types = {} @_provisioner_types = {}
# Get all the configured provisioners # 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 # Instantiate the provisioner
klass = Vagrant.plugin("2").manager.provisioners[provisioner.name] 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 # Store in the type map so that --provision-with works properly
@_provisioner_types[result] = provisioner.name @_provisioner_types[result] = provisioner.name

View File

@ -51,7 +51,7 @@ module Vagrant
end end
# Ask the provisioners to modify the configuration if needed # 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) p.configure(env[:machine].config)
end end
@ -60,7 +60,7 @@ module Vagrant
# Actually provision if we enabled it # Actually provision if we enabled it
if enabled if enabled
provisioner_instances.each do |p| provisioner_instances(env).each do |p|
next if env[:provision_types] && \ next if env[:provision_types] && \
!env[:provision_types].include?(provisioner_type_map[p]) !env[:provision_types].include?(provisioner_type_map[p])

View File

@ -28,7 +28,7 @@ module Vagrant
def do_cleanup(env) def do_cleanup(env)
# Ask the provisioners to modify the configuration if needed # 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( env[:ui].info(I18n.t(
"vagrant.provisioner_cleanup", "vagrant.provisioner_cleanup",
name: provisioner_type_map[p].to_s)) name: provisioner_type_map[p].to_s))