From aa1abdd1c4bb95d074d68d28a58728ba166a04a3 Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Tue, 15 Apr 2014 19:54:02 -0700 Subject: [PATCH] core: SSHExec middleware can have ssh info overridden --- lib/vagrant/action/builtin/ssh_exec.rb | 5 +++-- test/unit/vagrant/action/builtin/ssh_exec_test.rb | 10 ++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/lib/vagrant/action/builtin/ssh_exec.rb b/lib/vagrant/action/builtin/ssh_exec.rb index bd9197b9d..23b209066 100644 --- a/lib/vagrant/action/builtin/ssh_exec.rb +++ b/lib/vagrant/action/builtin/ssh_exec.rb @@ -21,8 +21,9 @@ module Vagrant end def call(env) - # Grab the SSH info from the machine - info = env[:machine].ssh_info + # Grab the SSH info from the machine or the environment + info = env[:ssh_info] + info ||= env[:machine].ssh_info # If the result is nil, then the machine is telling us that it is # not yet ready for SSH, so we raise this exception. diff --git a/test/unit/vagrant/action/builtin/ssh_exec_test.rb b/test/unit/vagrant/action/builtin/ssh_exec_test.rb index d2ba286c6..5662321e0 100644 --- a/test/unit/vagrant/action/builtin/ssh_exec_test.rb +++ b/test/unit/vagrant/action/builtin/ssh_exec_test.rb @@ -46,6 +46,16 @@ describe Vagrant::Action::Builtin::SSHExec do described_class.new(app, env).call(env) end + it "should exec with the SSH info in the env if given" do + ssh_info = { foo: :bar } + + expect(ssh_klass).to receive(:exec). + with(ssh_info, nil) + + env[:ssh_info] = ssh_info + described_class.new(app, env).call(env) + end + it "should exec with the options given in `ssh_opts`" do ssh_opts = { :foo => :bar }