Redo how each provisioners are sorted
This commit is contained in:
parent
28ef368881
commit
c189e4d255
|
@ -90,20 +90,23 @@ module Vagrant
|
||||||
# Add :each and :all provisioners in reverse to preserve order in Vagrantfile
|
# Add :each and :all provisioners in reverse to preserve order in Vagrantfile
|
||||||
|
|
||||||
# add each to final array
|
# add each to final array
|
||||||
# TODO: Account for additional tmp_final size after insert for BOTH before/after cases (if both shortcuts are used)
|
# TODO: This doesn't work if before each provisioners are defined before after provisioners
|
||||||
|
#
|
||||||
|
# Maybe do before and after individually instead??
|
||||||
tmp_final_provs = final_provs.dup
|
tmp_final_provs = final_provs.dup
|
||||||
before_extra_index = 1 # offset for final array size
|
index_offset = 0
|
||||||
after_extra_index = 0
|
|
||||||
each_provs.reverse_each do |p,options|
|
|
||||||
idx = 0
|
|
||||||
final_provs.each_with_index.map do |(prv,o), i|
|
final_provs.each_with_index.map do |(prv,o), i|
|
||||||
|
each_provs.reverse_each do |p, options|
|
||||||
|
idx = 0
|
||||||
if options[:before]
|
if options[:before]
|
||||||
idx = (i+before_extra_index)-1 unless i == 0
|
idx = (i+index_offset+1)-1 unless i == 0
|
||||||
before_extra_index += 1
|
puts "b: #{idx}"
|
||||||
|
index_offset += 1
|
||||||
tmp_final_provs.insert(idx, [p,options])
|
tmp_final_provs.insert(idx, [p,options])
|
||||||
elsif options[:after]
|
elsif options[:after]
|
||||||
idx = (i+after_extra_index)+1
|
idx = (i+index_offset)+1
|
||||||
after_extra_index += 1
|
index_offset += 1
|
||||||
|
puts "a: #{idx}"
|
||||||
tmp_final_provs.insert(idx, [p,options])
|
tmp_final_provs.insert(idx, [p,options])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -133,6 +136,13 @@ module Vagrant
|
||||||
# Return the type map
|
# Return the type map
|
||||||
@_provisioner_types
|
@_provisioner_types
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# @private
|
||||||
|
# Reset the cached values for platform. This is not considered a public
|
||||||
|
# API and should only be used for testing.
|
||||||
|
def self.reset!
|
||||||
|
instance_variables.each(&method(:remove_instance_variable))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -42,6 +42,7 @@ describe Vagrant::Action::Builtin::MixinProvisioners do
|
||||||
|
|
||||||
after do
|
after do
|
||||||
sandbox.close
|
sandbox.close
|
||||||
|
described_class.reset!
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "#provisioner_instances" do
|
describe "#provisioner_instances" do
|
||||||
|
|
Loading…
Reference in New Issue