File tree 5 files changed +32
-1
lines changed
5 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,8 @@ def ssh_config_args
101
101
""
102
102
when false
103
103
" -F none"
104
+ when String
105
+ " -F #{ Shellwords . escape ( config . ssh . config ) } "
104
106
end
105
107
end
106
108
end
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 @@ -300,6 +300,11 @@ class CommandsAppTest < ActiveSupport::TestCase
300
300
assert_equal "ssh -t root@1.1.1.1 -p 2222 'ls'" , new_command . run_over_ssh ( "ls" , host : "1.1.1.1" )
301
301
end
302
302
303
+ test "run over ssh with custom config" do
304
+ @config [ :ssh ] = { "config" => "config/ssh config" }
305
+ 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" )
306
+ end
307
+
303
308
test "run over ssh with no config" do
304
309
@config [ :ssh ] = { "config" => false }
305
310
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