Add a proxy command option to SSH commands
Now with more tests! Kinda. Closes #207
This commit is contained in:
parent
33ac3fd574
commit
740f73eb64
|
@ -86,7 +86,7 @@ module VagrantPlugins
|
||||||
"rsync", "--verbose", "--archive", "-z",
|
"rsync", "--verbose", "--archive", "-z",
|
||||||
*excludes.map{|e|['--exclude', e]}.flatten,
|
*excludes.map{|e|['--exclude', e]}.flatten,
|
||||||
"-e", "ssh -p #{ssh_info[:port]} #{ssh_key_options(ssh_info)} " +
|
"-e", "ssh -p #{ssh_info[:port]} #{ssh_key_options(ssh_info)} " +
|
||||||
ssh_options.map { |ssh_option| "-o '#{ssh_option}' " }.join,
|
ssh_options_to_args(ssh_options).join(' '),
|
||||||
hostpath,
|
hostpath,
|
||||||
"#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
|
"#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]
|
||||||
|
|
||||||
|
@ -106,6 +106,18 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Generate a ssh(1) command line list of options
|
||||||
|
#
|
||||||
|
# @param [Array] options An array of ssh options. E.g.
|
||||||
|
# `StrictHostKeyChecking=no` see ssh_config(5) for more
|
||||||
|
# @return [Array] Computed list of command line arguments
|
||||||
|
def ssh_options_to_args(options)
|
||||||
|
# Bail early if we get something that is not an array of options
|
||||||
|
return [] unless options
|
||||||
|
|
||||||
|
return options.map { |o| "-o '#{o}'" }
|
||||||
|
end
|
||||||
|
|
||||||
private
|
private
|
||||||
|
|
||||||
def ssh_key_options(ssh_info)
|
def ssh_key_options(ssh_info)
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
|
|
@ -0,0 +1,28 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
require 'vagrant-aws/action/sync_folders'
|
||||||
|
|
||||||
|
describe VagrantPlugins::AWS::Action::SyncFolders do
|
||||||
|
let(:app) { nil }
|
||||||
|
let(:env) { {} }
|
||||||
|
subject(:action) { described_class.new(app, env) }
|
||||||
|
|
||||||
|
describe '#ssh_options_to_args' do
|
||||||
|
subject(:args) { action.ssh_options_to_args(options) }
|
||||||
|
|
||||||
|
context 'with no ssh options' do
|
||||||
|
let(:options) { [] }
|
||||||
|
|
||||||
|
it { should eql [] }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with one option' do
|
||||||
|
let(:options) { ['StrictHostKeyChecking=no'] }
|
||||||
|
it { should eql ["-o 'StrictHostKeyChecking=no'"] }
|
||||||
|
end
|
||||||
|
|
||||||
|
context 'with multiple options' do
|
||||||
|
let(:options) { ['SHKC=no', 'Port=222'] }
|
||||||
|
it { should eql ["-o 'SHKC=no'", "-o 'Port=222'"] }
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue