diff --git a/lib/vagrant/action/multistep.rb b/lib/vagrant/action/multistep.rb index d30702d4e..7a74adaa4 100644 --- a/lib/vagrant/action/multistep.rb +++ b/lib/vagrant/action/multistep.rb @@ -78,10 +78,22 @@ module Vagrant maps[direct] = direct.variable end + # Take the missing inputs and map them together. For example + # the input of ':a' maps directly to the previous output of ':a' + (step_class.inputs - maps.values).each do |input| + maps[input] = input + end + # Turn the pure symbols into mapping from last steps maps.keys.each do |from| if from.kind_of?(Symbol) - new_from = output(@step_names.last, from) + new_from = nil + if @step_names.last.nil? + new_from = input(from) + else + new_from = output(@step_names.last, from) + end + maps[new_from] = maps.delete(from) end end @@ -122,10 +134,6 @@ module Vagrant elsif from.kind_of?(StepOutput) # Step outputs get their data from a previous step's output. inputs[to] = step_outputs[from.name][from.variable] - else - # A basic remapping remaps the previous steps outputs to an - # input for this step. - inputs[to] = inputs.delete(from) end end diff --git a/test/unit/vagrant/action/multistep_test.rb b/test/unit/vagrant/action/multistep_test.rb index 2cc4e7e3a..70e4d631e 100644 --- a/test/unit/vagrant/action/multistep_test.rb +++ b/test/unit/vagrant/action/multistep_test.rb @@ -137,6 +137,20 @@ describe Vagrant::Action::MultiStep do expect { g.step :foo }.to raise_error(ArgumentError) end + it "should not allow a step that doesn't have all inputs satisfied" do + step_A = Class.new(Vagrant::Action::Step) do + output :output_A + end + + step_B = Class.new(Vagrant::Action::Step) do + input :input_B + end + + g = described_class.new + g.step step_A + expect { g.step step_B }.to raise_error(ArgumentError) + end + it "should not allow remapping from outputs that don't exist" do step_A = Class.new(Vagrant::Action::Step) do output :output_A