Class: Kamal::Lint::Checks::RoleHostsEmpty

Inherits:
Kamal::Lint::Check show all
Defined in:
lib/kamal/lint/checks/role_hosts_empty.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



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

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

  findings = []
  servers.each do |role, entry|
    hosts = ServersHelper.extract_hosts(entry)
    next unless hosts.empty?

    findings << finding(
      message: "role `#{role}` under `servers` has no hosts; deploys to this role will silently no-op",
      line: context.line_for([ "servers", role.to_s ])
    )
  end
  findings
end