Class: Kamal::Lint::Checks::SslWithoutHost

Inherits:
Kamal::Lint::Check show all
Defined in:
lib/kamal/lint/checks/ssl_without_host.rb

Instance Attribute Summary

Attributes inherited from Kamal::Lint::Check

#context

Instance Method Summary collapse

Methods inherited from Kamal::Lint::Check

applies_to?, autofixable, id, #initialize, severity, since, title, until_version

Constructor Details

This class inherits a constructor from Kamal::Lint::Check

Instance Method Details

#callObject



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/kamal/lint/checks/ssl_without_host.rb', line 12

def call
  proxy = parsed["proxy"]
  return [] unless proxy.is_a?(Hash)

  ssl_enabled = proxy["ssl"] == true
  return [] unless ssl_enabled

  host = proxy["host"]
  hosts = proxy["hosts"]

  host_set = (host.is_a?(String) && !host.empty?) ||
             (hosts.is_a?(Array) && hosts.any? { |h| h.is_a?(String) && !h.empty? })

  return [] if host_set

  [ finding(
    message: "proxy.ssl: true requires `host:` (or `hosts:`) to be set for automatic Let's Encrypt provisioning",
    line: context.line_for([ "proxy", "ssl" ]) || context.line_for([ "proxy" ])
  ) ]
end