Class: Kamal::Cli::App::SslCertificates

Inherits:
Object
  • Object
show all
Defined in:
lib/kamal/cli/app/ssl_certificates.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, role, sshkit) ⇒ SslCertificates

Returns a new instance of SslCertificates.



5
6
7
8
9
# File 'lib/kamal/cli/app/ssl_certificates.rb', line 5

def initialize(host, role, sshkit)
  @host = host
  @role = role
  @sshkit = sshkit
end

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



2
3
4
# File 'lib/kamal/cli/app/ssl_certificates.rb', line 2

def host
  @host
end

#roleObject (readonly)

Returns the value of attribute role.



2
3
4
# File 'lib/kamal/cli/app/ssl_certificates.rb', line 2

def role
  @role
end

#sshkitObject (readonly)

Returns the value of attribute sshkit.



2
3
4
# File 'lib/kamal/cli/app/ssl_certificates.rb', line 2

def sshkit
  @sshkit
end

Instance Method Details

#runObject



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/kamal/cli/app/ssl_certificates.rb', line 11

def run
  if role.running_proxy? && role.proxy.custom_ssl_certificate?
    info "Writing SSL certificates for #{role.name} on #{host}"
    execute *app.create_ssl_directory
    if cert_content = role.proxy.certificate_pem_content
      upload!(StringIO.new(cert_content), role.proxy.host_tls_cert, mode: "0644")
    end
    if key_content = role.proxy.private_key_pem_content
      upload!(StringIO.new(key_content), role.proxy.host_tls_key, mode: "0644")
    end
  end
end