Pass around Roles instead of Strings
Avoid looking up roles by names everywhere. This avoids the awkward role/role_config naming as well.
This commit is contained in:
@@ -13,9 +13,8 @@ class Kamal::Cli::App < Kamal::Cli::Base
|
||||
|
||||
KAMAL.roles_on(host).each do |role|
|
||||
app = KAMAL.app(role: role)
|
||||
role_config = KAMAL.config.role(role)
|
||||
|
||||
if role_config.assets?
|
||||
if role.assets?
|
||||
execute *app.extract_assets
|
||||
old_version = capture_with_info(*app.current_running_version, raise_on_non_zero_exit: false).strip
|
||||
execute *app.sync_asset_volumes(old_version: old_version)
|
||||
@@ -27,7 +26,6 @@ class Kamal::Cli::App < Kamal::Cli::Base
|
||||
KAMAL.roles_on(host).each do |role|
|
||||
app = KAMAL.app(role: role)
|
||||
auditor = KAMAL.auditor(role: role)
|
||||
role_config = KAMAL.config.role(role)
|
||||
|
||||
if capture_with_info(*app.container_id_for_version(version), raise_on_non_zero_exit: false).present?
|
||||
tmp_version = "#{version}_replaced_#{SecureRandom.hex(8)}"
|
||||
@@ -38,7 +36,7 @@ class Kamal::Cli::App < Kamal::Cli::Base
|
||||
|
||||
old_version = capture_with_info(*app.current_running_version, raise_on_non_zero_exit: false).strip
|
||||
|
||||
execute *app.tie_cord(role_config.cord_host_file) if role_config.uses_cord?
|
||||
execute *app.tie_cord(role.cord_host_file) if role.uses_cord?
|
||||
|
||||
execute *auditor.record("Booted app version #{version}"), verbosity: :debug
|
||||
|
||||
@@ -47,7 +45,7 @@ class Kamal::Cli::App < Kamal::Cli::Base
|
||||
Kamal::Cli::Healthcheck::Poller.wait_for_healthy(pause_after_ready: true) { capture_with_info(*app.status(version: version)) }
|
||||
|
||||
if old_version.present?
|
||||
if role_config.uses_cord?
|
||||
if role.uses_cord?
|
||||
cord = capture_with_info(*app.cord(version: old_version), raise_on_non_zero_exit: false).strip
|
||||
if cord.present?
|
||||
execute *app.cut_cord(cord)
|
||||
@@ -57,7 +55,7 @@ class Kamal::Cli::App < Kamal::Cli::Base
|
||||
|
||||
execute *app.stop(version: old_version), raise_on_non_zero_exit: false
|
||||
|
||||
execute *app.clean_up_assets if role_config.assets?
|
||||
execute *app.clean_up_assets if role.assets?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user