-
Notifications
You must be signed in to change notification settings - Fork 458
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow
ssh/config
to additionally accept a string, or an array of st…
…rings This is accepted by Net::SSH, research done by @jeremy in #908 (comment) This is already documented as working correctly in https://github.com/basecamp/kamal/blob/74a06b0ccda616c86ebe1729d0795f39bcac9f00/lib/kamal/configuration/docs/ssh.yml#L65-L70 However, before this change only booleans were allowed because of the example configuration file.
- Loading branch information
1 parent
f924b68
commit 14cde2c
Showing
2 changed files
with
26 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class Kamal::Configuration::Validator::Ssh < Kamal::Configuration::Validator | ||
BOOLEAN_OR_STRING_OR_ARRAY_OF_STRING_KEYS = [ "config" ] | ||
SPECIAL_KEYS = BOOLEAN_OR_STRING_OR_ARRAY_OF_STRING_KEYS | ||
|
||
def validate! | ||
validate_against_example! \ | ||
config.except(*SPECIAL_KEYS), | ||
example.except(*SPECIAL_KEYS) | ||
|
||
BOOLEAN_OR_STRING_OR_ARRAY_OF_STRING_KEYS.each do |key| | ||
value = config[key] | ||
|
||
with_context(key) do | ||
validate_type! value, TrueClass, String, Array | ||
validate_array_of!(value, String) if value.is_a?(Array) | ||
end | ||
end | ||
end | ||
|
||
private | ||
|
||
def special_keys | ||
@special_keys ||= config.keys & SPECIAL_KEYS | ||
end | ||
end |