Skip to content
This repository has been archived by the owner on Feb 11, 2022. It is now read-only.

Commit

Permalink
Add a proxy command option to SSH commands
Browse files Browse the repository at this point in the history
Now with more tests! Kinda.

Closes #207
  • Loading branch information
R. Tyler Croy committed May 30, 2014
1 parent 33ac3fd commit 740f73e
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 1 deletion.
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--format doc --order random --color --fail-fast
14 changes: 13 additions & 1 deletion lib/vagrant-aws/action/sync_folders.rb
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ def call(env)
"rsync", "--verbose", "--archive", "-z",
*excludes.map{|e|['--exclude', e]}.flatten,
"-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,
"#{ssh_info[:username]}@#{ssh_info[:host]}:#{guestpath}"]

Expand All @@ -106,6 +106,18 @@ def call(env)
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

def ssh_key_options(ssh_info)
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

28 changes: 28 additions & 0 deletions spec/vagrant-aws/actions/syncfolders_spec.rb
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 740f73e

Please sign in to comment.