Extract helper
This commit is contained in:
@@ -134,13 +134,7 @@ class Mrsk::Cli::App < Mrsk::Cli::Base
|
|||||||
roles = MRSK.roles_on(host)
|
roles = MRSK.roles_on(host)
|
||||||
|
|
||||||
roles.each do |role|
|
roles.each do |role|
|
||||||
stale_versions = \
|
stale_versions(role: role).each do |version|
|
||||||
capture_with_info(*MRSK.app(role: role).list_versions, raise_on_non_zero_exit: false)
|
|
||||||
.split("\n")
|
|
||||||
.map(&:strip)
|
|
||||||
.drop(1)
|
|
||||||
|
|
||||||
stale_versions.each do |version|
|
|
||||||
if stop
|
if stop
|
||||||
puts_by_host host, "Stopping stale container for role #{role} with version #{version}"
|
puts_by_host host, "Stopping stale container for role #{role} with version #{version}"
|
||||||
execute *MRSK.app(role: role).stop(version: version), raise_on_non_zero_exit: false
|
execute *MRSK.app(role: role).stop(version: version), raise_on_non_zero_exit: false
|
||||||
|
|||||||
@@ -1,7 +1,17 @@
|
|||||||
require "sshkit"
|
require "sshkit"
|
||||||
require "sshkit/dsl"
|
require "sshkit/dsl"
|
||||||
|
|
||||||
|
module AppHelper
|
||||||
|
def stale_versions(role:)
|
||||||
|
capture_with_info(*MRSK.app(role: role).list_versions, raise_on_non_zero_exit: false)
|
||||||
|
.split("\n")
|
||||||
|
.drop(1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
class SSHKit::Backend::Abstract
|
class SSHKit::Backend::Abstract
|
||||||
|
include AppHelper
|
||||||
|
|
||||||
def capture_with_info(*args, **kwargs)
|
def capture_with_info(*args, **kwargs)
|
||||||
capture(*args, **kwargs, verbosity: Logger::INFO)
|
capture(*args, **kwargs, verbosity: Logger::INFO)
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user