forked from basecamp/kamal
-
Notifications
You must be signed in to change notification settings - Fork 0
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 accept string, or array of strings
This gets passed through to SSHKit options. See basecamp#908 Documentation mentions a string or array of strings are allowed, but they are not because: * Validator example supplies a boolean, so only true/false are enabled. * `Kamal::Configuration::Ssh#options` doesn't expose `config`, used in lib/kamal/commander.rb:167
- Loading branch information
1 parent
74a06b0
commit 703e19b
Showing
2 changed files
with
31 additions
and
2 deletions.
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 |