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
12
|
# File 'lib/kamal/configuration/ssh.rb', line 8
def initialize(config:)
@ssh_config = config.raw_config.ssh || {}
@secrets = config.secrets
validate! ssh_config
end
|
Instance Attribute Details
#secrets ⇒ Object
Returns the value of attribute secrets.
6
7
8
|
# File 'lib/kamal/configuration/ssh.rb', line 6
def secrets
@secrets
end
|
#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
#config ⇒ Object
52
53
54
|
# File 'lib/kamal/configuration/ssh.rb', line 52
def config
ssh_config["config"]
end
|
#key_data ⇒ Object
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# File 'lib/kamal/configuration/ssh.rb', line 38
def key_data
key_data = ssh_config["key_data"]
return unless key_data
key_data.map do |k|
if secrets.key?(k)
secrets[k]
else
warn "Inline key_data usage is deprecated and will be removed in Kamal 3. Please store your key_data in a secret."
k
end
end
end
|
#keys ⇒ Object
34
35
36
|
# File 'lib/kamal/configuration/ssh.rb', line 34
def keys
ssh_config["keys"]
end
|
#keys_only ⇒ Object
30
31
32
|
# File 'lib/kamal/configuration/ssh.rb', line 30
def keys_only
ssh_config["keys_only"]
end
|
#options ⇒ Object
56
57
58
|
# File 'lib/kamal/configuration/ssh.rb', line 56
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, config: config }.compact
end
|
#port ⇒ Object
18
19
20
|
# File 'lib/kamal/configuration/ssh.rb', line 18
def port
ssh_config.fetch("port", 22)
end
|
#proxy ⇒ Object
22
23
24
25
26
27
28
|
# File 'lib/kamal/configuration/ssh.rb', line 22
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
60
61
62
|
# File 'lib/kamal/configuration/ssh.rb', line 60
def to_h
options.except(:logger).merge(log_level: log_level)
end
|
#user ⇒ Object
14
15
16
|
# File 'lib/kamal/configuration/ssh.rb', line 14
def user
ssh_config.fetch("user", "root")
end
|