File tree Expand file tree Collapse file tree 5 files changed +32
-1
lines changed Expand file tree Collapse file tree 5 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -117,6 +117,8 @@ def ssh_config_args
117
117
""
118
118
when false
119
119
" -F none"
120
+ when String
121
+ " -F #{ Shellwords . escape ( config . ssh . config ) } "
120
122
end
121
123
end
122
124
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ class Kamal::Configuration::Ssh
7
7
8
8
def initialize ( config :)
9
9
@ssh_config = config . raw_config . ssh || { }
10
- validate! ssh_config
10
+ validate! ssh_config , with : Kamal :: Configuration :: Validator :: Ssh
11
11
end
12
12
13
13
def user
Original file line number Diff line number Diff line change
1
+ class Kamal ::Configuration ::Validator ::Ssh < Kamal ::Configuration ::Validator
2
+ SPECIAL_KEYS = [ "config" ]
3
+
4
+ def validate!
5
+ validate_against_example! \
6
+ config . except ( *SPECIAL_KEYS ) ,
7
+ example . except ( *SPECIAL_KEYS )
8
+
9
+ validate_config_key! if config . key? ( "config" )
10
+ end
11
+
12
+ private
13
+
14
+ def validate_config_key!
15
+ with_context ( config [ "config" ] ) do
16
+ validate_type! config [ "config" ] , TrueClass , String
17
+ end
18
+ end
19
+ end
Original file line number Diff line number Diff line change @@ -324,6 +324,11 @@ class CommandsAppTest < ActiveSupport::TestCase
324
324
assert_equal "ssh -t root@1.1.1.1 -p 2222 'ls'" , new_command . run_over_ssh ( "ls" , host : "1.1.1.1" )
325
325
end
326
326
327
+ test "run over ssh with custom config" do
328
+ @config [ :ssh ] = { "config" => "config/ssh config" }
329
+ assert_equal "ssh -F config/ssh\\ config -t root@1.1.1.1 -p 22 'ls'" , new_command . run_over_ssh ( "ls" , host : "1.1.1.1" )
330
+ end
331
+
327
332
test "run over ssh with no config" do
328
333
@config [ :ssh ] = { "config" => false }
329
334
assert_equal "ssh -F none -t root@1.1.1.1 -p 22 'ls'" , new_command . run_over_ssh ( "ls" , host : "1.1.1.1" )
Original file line number Diff line number Diff line change @@ -42,4 +42,9 @@ class ConfigurationSshTest < ActiveSupport::TestCase
42
42
config = Kamal ::Configuration . new ( @deploy . tap { |c | c . merge! ( ssh : { "config" => false } ) } )
43
43
assert_equal false , config . ssh . options [ :config ]
44
44
end
45
+
46
+ test "ssh options with path to an ssh_config-file" do
47
+ config = Kamal ::Configuration . new ( @deploy . tap { |c | c . merge! ( ssh : { "config" => "config/ssh_config" } ) } )
48
+ assert_equal "config/ssh_config" , config . ssh . options [ :config ]
49
+ end
45
50
end
You can’t perform that action at this time.
0 commit comments