Class: Kamal::Cli::Proxy::Drift

Inherits:
Object
  • Object
show all
Defined in:
lib/kamal/cli/proxy/drift.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(host, sshkit) ⇒ Drift

Returns a new instance of Drift.



5
6
7
8
# File 'lib/kamal/cli/proxy/drift.rb', line 5

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

Instance Attribute Details

#hostObject (readonly)

Returns the value of attribute host.



2
3
4
# File 'lib/kamal/cli/proxy/drift.rb', line 2

def host
  @host
end

#sshkitObject (readonly)

Returns the value of attribute sshkit.



2
3
4
# File 'lib/kamal/cli/proxy/drift.rb', line 2

def sshkit
  @sshkit
end

Instance Method Details

#container_exists?Boolean

Returns:

  • (Boolean)


10
11
12
# File 'lib/kamal/cli/proxy/drift.rb', line 10

def container_exists?
  capture_with_info(*proxy.container_id, raise_on_non_zero_exit: false).strip.present?
end

#drifted?Boolean

A proxy container has drifted when it was started with a different config digest than the one the current configuration produces. Containers booted by older kamal versions carry no digest label and count as drifted, so they converge on the first deploy after upgrading.

Returns:

  • (Boolean)


18
19
20
21
# File 'lib/kamal/cli/proxy/drift.rb', line 18

def drifted?
  return @drifted if defined?(@drifted)
  @drifted = container_exists? && current_digest != expected_digest
end

#expected_digestObject



23
24
25
26
27
28
29
# File 'lib/kamal/cli/proxy/drift.rb', line 23

def expected_digest
  @expected_digest ||= if proxy.proxy_run_config
    proxy.proxy_run_config.config_digest
  else
    Kamal::Configuration::Proxy::Run.digest(capture_with_info(*proxy.boot_config).strip)
  end
end