Class: Mrsk::Commander
- Inherits:
-
Object
- Object
- Mrsk::Commander
- Defined in:
- lib/mrsk/commander.rb
Instance Attribute Summary collapse
-
#hold_lock_on_error ⇒ Object
Returns the value of attribute hold_lock_on_error.
-
#holding_lock ⇒ Object
Returns the value of attribute holding_lock.
-
#specific_hosts ⇒ Object
Returns the value of attribute specific_hosts.
-
#specific_roles ⇒ Object
Returns the value of attribute specific_roles.
-
#verbosity ⇒ Object
Returns the value of attribute verbosity.
Instance Method Summary collapse
- #accessory(name) ⇒ Object
- #accessory_hosts ⇒ Object
- #accessory_names ⇒ Object
- #app(role: nil) ⇒ Object
- #auditor(**details) ⇒ Object
- #boot_strategy ⇒ Object
- #builder ⇒ Object
- #config ⇒ Object
- #configure(**kwargs) ⇒ Object
- #docker ⇒ Object
- #healthcheck ⇒ Object
- #hold_lock_on_error? ⇒ Boolean
- #holding_lock? ⇒ Boolean
- #hook ⇒ Object
- #hosts ⇒ Object
-
#initialize ⇒ Commander
constructor
A new instance of Commander.
- #lock ⇒ Object
- #primary_host ⇒ Object
- #prune ⇒ Object
- #registry ⇒ Object
- #roles ⇒ Object
- #roles_on(host) ⇒ Object
- #specific_primary! ⇒ Object
- #traefik ⇒ Object
- #traefik_hosts ⇒ Object
- #with_verbosity(level) ⇒ Object
Constructor Details
#initialize ⇒ Commander
Returns a new instance of Commander.
7 8 9 10 11 |
# File 'lib/mrsk/commander.rb', line 7 def initialize self.verbosity = :info self.holding_lock = false self.hold_lock_on_error = false end |
Instance Attribute Details
#hold_lock_on_error ⇒ Object
Returns the value of attribute hold_lock_on_error.
5 6 7 |
# File 'lib/mrsk/commander.rb', line 5 def hold_lock_on_error @hold_lock_on_error end |
#holding_lock ⇒ Object
Returns the value of attribute holding_lock.
5 6 7 |
# File 'lib/mrsk/commander.rb', line 5 def holding_lock @holding_lock end |
#specific_hosts ⇒ Object
Returns the value of attribute specific_hosts.
24 25 26 |
# File 'lib/mrsk/commander.rb', line 24 def specific_hosts @specific_hosts end |
#specific_roles ⇒ Object
Returns the value of attribute specific_roles.
24 25 26 |
# File 'lib/mrsk/commander.rb', line 24 def specific_roles @specific_roles end |
#verbosity ⇒ Object
Returns the value of attribute verbosity.
5 6 7 |
# File 'lib/mrsk/commander.rb', line 5 def verbosity @verbosity end |
Instance Method Details
#accessory(name) ⇒ Object
83 84 85 |
# File 'lib/mrsk/commander.rb', line 83 def accessory(name) Mrsk::Commands::Accessory.new(config, name: name) end |
#accessory_hosts ⇒ Object
70 71 72 |
# File 'lib/mrsk/commander.rb', line 70 def accessory_hosts specific_hosts || config.accessories.flat_map(&:hosts) end |
#accessory_names ⇒ Object
74 75 76 |
# File 'lib/mrsk/commander.rb', line 74 def accessory_names config.accessories&.collect(&:name) || [] end |
#app(role: nil) ⇒ Object
79 80 81 |
# File 'lib/mrsk/commander.rb', line 79 def app(role: nil) Mrsk::Commands::App.new(config, role: role) end |
#auditor(**details) ⇒ Object
87 88 89 |
# File 'lib/mrsk/commander.rb', line 87 def auditor(**details) Mrsk::Commands::Auditor.new(config, **details) end |
#boot_strategy ⇒ Object
54 55 56 57 58 59 60 |
# File 'lib/mrsk/commander.rb', line 54 def boot_strategy if config.boot.limit.present? { in: :groups, limit: config.boot.limit, wait: config.boot.wait } else {} end end |
#builder ⇒ Object
91 92 93 |
# File 'lib/mrsk/commander.rb', line 91 def builder @builder ||= Mrsk::Commands::Builder.new(config) end |
#config ⇒ Object
13 14 15 16 17 18 |
# File 'lib/mrsk/commander.rb', line 13 def config @config ||= Mrsk::Configuration.create_from(**@config_kwargs).tap do |config| @config_kwargs = nil configure_sshkit_with(config) end end |
#configure(**kwargs) ⇒ Object
20 21 22 |
# File 'lib/mrsk/commander.rb', line 20 def configure(**kwargs) @config, @config_kwargs = nil, kwargs end |
#docker ⇒ Object
95 96 97 |
# File 'lib/mrsk/commander.rb', line 95 def docker @docker ||= Mrsk::Commands::Docker.new(config) end |
#healthcheck ⇒ Object
99 100 101 |
# File 'lib/mrsk/commander.rb', line 99 def healthcheck @healthcheck ||= Mrsk::Commands::Healthcheck.new(config) end |
#hold_lock_on_error? ⇒ Boolean
139 140 141 |
# File 'lib/mrsk/commander.rb', line 139 def hold_lock_on_error? self.hold_lock_on_error end |
#holding_lock? ⇒ Boolean
135 136 137 |
# File 'lib/mrsk/commander.rb', line 135 def holding_lock? self.holding_lock end |
#hook ⇒ Object
103 104 105 |
# File 'lib/mrsk/commander.rb', line 103 def hook @hook ||= Mrsk::Commands::Hook.new(config) end |
#hosts ⇒ Object
48 49 50 51 52 |
# File 'lib/mrsk/commander.rb', line 48 def hosts (specific_hosts || config.all_hosts).select do |host| (specific_roles || config.roles).flat_map(&:hosts).include?(host) end end |
#lock ⇒ Object
107 108 109 |
# File 'lib/mrsk/commander.rb', line 107 def lock @lock ||= Mrsk::Commands::Lock.new(config) end |
#primary_host ⇒ Object
38 39 40 |
# File 'lib/mrsk/commander.rb', line 38 def primary_host specific_hosts&.first || specific_roles&.first&.primary_host || config.primary_web_host end |
#prune ⇒ Object
111 112 113 |
# File 'lib/mrsk/commander.rb', line 111 def prune @prune ||= Mrsk::Commands::Prune.new(config) end |
#registry ⇒ Object
115 116 117 |
# File 'lib/mrsk/commander.rb', line 115 def registry @registry ||= Mrsk::Commands::Registry.new(config) end |
#roles ⇒ Object
42 43 44 45 46 |
# File 'lib/mrsk/commander.rb', line 42 def roles (specific_roles || config.roles).select do |role| ((specific_hosts || config.all_hosts) & role.hosts).any? end end |
#roles_on(host) ⇒ Object
62 63 64 |
# File 'lib/mrsk/commander.rb', line 62 def roles_on(host) roles.select { |role| role.hosts.include?(host.to_s) }.map(&:name) end |
#specific_primary! ⇒ Object
26 27 28 |
# File 'lib/mrsk/commander.rb', line 26 def specific_primary! self.specific_hosts = [ config.primary_web_host ] end |
#traefik ⇒ Object
119 120 121 |
# File 'lib/mrsk/commander.rb', line 119 def traefik @traefik ||= Mrsk::Commands::Traefik.new(config) end |
#traefik_hosts ⇒ Object
66 67 68 |
# File 'lib/mrsk/commander.rb', line 66 def traefik_hosts specific_hosts || config.traefik_hosts end |
#with_verbosity(level) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 |
# File 'lib/mrsk/commander.rb', line 123 def with_verbosity(level) old_level = self.verbosity self.verbosity = level SSHKit.config.output_verbosity = level yield ensure self.verbosity = old_level SSHKit.config.output_verbosity = old_level end |