Class: Kamal::Configuration::Ssh
- Inherits:
-
Object
- Object
- Kamal::Configuration::Ssh
show all
- Includes:
- Validation
- Defined in:
- lib/kamal/configuration/ssh.rb
Constant Summary
collapse
- LOGGER =
::Logger.new(STDERR)
Instance Attribute Summary collapse
Instance Method Summary
collapse
Methods included from Validation
#validate!, #validation_yml
Constructor Details
#initialize(config:) ⇒ Ssh
Returns a new instance of Ssh.
8
9
10
11
|
# File 'lib/kamal/configuration/ssh.rb', line 8
def initialize(config:)
@ssh_config = config.raw_config.ssh || {}
validate! ssh_config
end
|
Instance Attribute Details
#ssh_config ⇒ Object
Returns the value of attribute ssh_config.
6
7
8
|
# File 'lib/kamal/configuration/ssh.rb', line 6
def ssh_config
@ssh_config
end
|
Instance Method Details
#key_data ⇒ Object
37
38
39
|
# File 'lib/kamal/configuration/ssh.rb', line 37
def key_data
ssh_config["key_data"]
end
|
#keys ⇒ Object
33
34
35
|
# File 'lib/kamal/configuration/ssh.rb', line 33
def keys
ssh_config["keys"]
end
|
#keys_only ⇒ Object
29
30
31
|
# File 'lib/kamal/configuration/ssh.rb', line 29
def keys_only
ssh_config["keys_only"]
end
|
#options ⇒ Object
41
42
43
|
# File 'lib/kamal/configuration/ssh.rb', line 41
def options
{ user: user, port: port, proxy: proxy, logger: logger, keepalive: true, keepalive_interval: 30, keys_only: keys_only, keys: keys, key_data: key_data }.compact
end
|
#port ⇒ Object
17
18
19
|
# File 'lib/kamal/configuration/ssh.rb', line 17
def port
ssh_config.fetch("port", 22)
end
|
#proxy ⇒ Object
21
22
23
24
25
26
27
|
# File 'lib/kamal/configuration/ssh.rb', line 21
def proxy
if (proxy = ssh_config["proxy"])
Net::SSH::Proxy::Jump.new(proxy.include?("@") ? proxy : "root@#{proxy}")
elsif (proxy_command = ssh_config["proxy_command"])
Net::SSH::Proxy::Command.new(proxy_command)
end
end
|
#to_h ⇒ Object
45
46
47
|
# File 'lib/kamal/configuration/ssh.rb', line 45
def to_h
options.except(:logger).merge(log_level: log_level)
end
|
#user ⇒ Object
13
14
15
|
# File 'lib/kamal/configuration/ssh.rb', line 13
def user
ssh_config.fetch("user", "root")
end
|