Class: Kamal::Cli::Doctor

Inherits:
Object
  • Object
show all
Includes:
SSHKit::DSL
Defined in:
lib/kamal/cli/doctor.rb

Overview

Runs read-only deploy readiness checks and collects the results, without ever raising on a broken environment - failures become failing results instead.

Defined Under Namespace

Classes: ConfigChecks, EndpointChecks, HostChecks, Result

Constant Summary collapse

HOST_CHECKS =
%i[ ssh docker registry proxy_image proxy_version proxy_socket ports ]
CHECK_TITLES =
{
  ssh: "SSH",
  docker: "Docker",
  registry: "Registry",
  proxy_image: "Proxy image",
  proxy_version: "Proxy version",
  proxy_socket: "Proxy docker socket",
  ports: "Ports",
  dns: "DNS",
  certificate: "Certificates",
  readiness: "Readiness"
}.freeze
STATUS_COLORS =
{ ok: :green, warn: :yellow, fail: :red }.freeze

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDoctor

Returns a new instance of Doctor.



49
50
51
# File 'lib/kamal/cli/doctor.rb', line 49

def initialize
  @results = []
end

Instance Attribute Details

#resultsObject (readonly)

Returns the value of attribute results.



47
48
49
# File 'lib/kamal/cli/doctor.rb', line 47

def results
  @results
end

Instance Method Details

#failuresObject



57
58
59
# File 'lib/kamal/cli/doctor.rb', line 57

def failures
  results.select(&:fail?)
end

#runObject



53
54
55
# File 'lib/kamal/cli/doctor.rb', line 53

def run
  @results = host_check_results + endpoint_check_results + config_check_results
end

#successful?Boolean

Returns:

  • (Boolean)


65
66
67
# File 'lib/kamal/cli/doctor.rb', line 65

def successful?
  failures.none?
end

#warningsObject



61
62
63
# File 'lib/kamal/cli/doctor.rb', line 61

def warnings
  results.select(&:warn?)
end