File tree 2 files changed +26
-1
lines changed
2 files changed +26
-1
lines changed 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
+ BOOLEAN_OR_STRING_OR_ARRAY_OF_STRING_KEYS = [ "config" ]
3
+ SPECIAL_KEYS = BOOLEAN_OR_STRING_OR_ARRAY_OF_STRING_KEYS
4
+
5
+ def validate!
6
+ validate_against_example! \
7
+ config . except ( *SPECIAL_KEYS ) ,
8
+ example . except ( *SPECIAL_KEYS )
9
+
10
+ BOOLEAN_OR_STRING_OR_ARRAY_OF_STRING_KEYS . each do |key |
11
+ value = config [ key ]
12
+
13
+ with_context ( key ) do
14
+ validate_type! value , TrueClass , String , Array
15
+ validate_array_of! ( value , String ) if value . is_a? ( Array )
16
+ end
17
+ end
18
+ end
19
+
20
+ private
21
+
22
+ def special_keys
23
+ @special_keys ||= config . keys & SPECIAL_KEYS
24
+ end
25
+ end
You can’t perform that action at this time.
0 commit comments