Class: Kamal::Cli::Proxy::Drift
- Inherits:
-
Object
- Object
- Kamal::Cli::Proxy::Drift
- Defined in:
- lib/kamal/cli/proxy/drift.rb
Instance Attribute Summary collapse
-
#host ⇒ Object
readonly
Returns the value of attribute host.
-
#sshkit ⇒ Object
readonly
Returns the value of attribute sshkit.
Instance Method Summary collapse
- #container_exists? ⇒ Boolean
-
#drifted? ⇒ Boolean
A proxy container has drifted when it was started with a different config digest than the one the current configuration produces.
- #expected_digest ⇒ Object
-
#initialize(host, sshkit) ⇒ Drift
constructor
A new instance of Drift.
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
#host ⇒ Object (readonly)
Returns the value of attribute host.
2 3 4 |
# File 'lib/kamal/cli/proxy/drift.rb', line 2 def host @host end |
#sshkit ⇒ Object (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
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.
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_digest ⇒ Object
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 |