Class: Mrsk::Commander
- Inherits:
-
Object
- Object
- Mrsk::Commander
- Defined in:
- lib/mrsk/commander.rb
Instance Attribute Summary collapse
-
#config_file ⇒ Object
Returns the value of attribute config_file.
-
#destination ⇒ Object
Returns the value of attribute destination.
-
#specific_hosts ⇒ Object
Returns the value of attribute specific_hosts.
-
#verbosity ⇒ Object
Returns the value of attribute verbosity.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #accessory(name) ⇒ Object
- #accessory_hosts ⇒ Object
- #accessory_names ⇒ Object
- #app ⇒ Object
- #auditor ⇒ Object
- #builder ⇒ Object
- #config ⇒ Object
- #healthcheck ⇒ Object
- #hosts ⇒ Object
-
#initialize(config_file: nil, destination: nil, verbosity: :info) ⇒ Commander
constructor
A new instance of Commander.
- #primary_host ⇒ Object
- #prune ⇒ Object
- #registry ⇒ Object
-
#reset ⇒ Object
Test-induced damage!.
- #specific_primary! ⇒ Object
- #specific_roles=(role_names) ⇒ Object
- #traefik ⇒ Object
- #traefik_hosts ⇒ Object
- #with_verbosity(level) ⇒ Object
Constructor Details
#initialize(config_file: nil, destination: nil, verbosity: :info) ⇒ Commander
Returns a new instance of Commander.
6 7 8 |
# File 'lib/mrsk/commander.rb', line 6 def initialize(config_file: nil, destination: nil, verbosity: :info) @config_file, @destination, @verbosity = config_file, destination, verbosity end |
Instance Attribute Details
#config_file ⇒ Object
Returns the value of attribute config_file.
4 5 6 |
# File 'lib/mrsk/commander.rb', line 4 def config_file @config_file end |
#destination ⇒ Object
Returns the value of attribute destination.
4 5 6 |
# File 'lib/mrsk/commander.rb', line 4 def destination @destination end |
#specific_hosts ⇒ Object
Returns the value of attribute specific_hosts.
17 18 19 |
# File 'lib/mrsk/commander.rb', line 17 def specific_hosts @specific_hosts end |
#verbosity ⇒ Object
Returns the value of attribute verbosity.
4 5 6 |
# File 'lib/mrsk/commander.rb', line 4 def verbosity @verbosity end |
#version ⇒ Object
Returns the value of attribute version.
4 5 6 |
# File 'lib/mrsk/commander.rb', line 4 def version @version end |
Instance Method Details
#accessory(name) ⇒ Object
68 69 70 |
# File 'lib/mrsk/commander.rb', line 68 def accessory(name) Mrsk::Commands::Accessory.new(config, name: name) end |
#accessory_hosts ⇒ Object
39 40 41 |
# File 'lib/mrsk/commander.rb', line 39 def accessory_hosts specific_hosts || config.accessories.collect(&:host) end |
#accessory_names ⇒ Object
43 44 45 |
# File 'lib/mrsk/commander.rb', line 43 def accessory_names config.accessories&.collect(&:name) || [] end |
#app ⇒ Object
48 49 50 |
# File 'lib/mrsk/commander.rb', line 48 def app @app ||= Mrsk::Commands::App.new(config) end |
#auditor ⇒ Object
72 73 74 |
# File 'lib/mrsk/commander.rb', line 72 def auditor @auditor ||= Mrsk::Commands::Auditor.new(config) end |
#builder ⇒ Object
52 53 54 |
# File 'lib/mrsk/commander.rb', line 52 def builder @builder ||= Mrsk::Commands::Builder.new(config) end |
#config ⇒ Object
10 11 12 13 14 15 |
# File 'lib/mrsk/commander.rb', line 10 def config @config ||= \ Mrsk::Configuration .create_from(config_file, destination: destination, version: cascading_version) .tap { |config| configure_sshkit_with(config) } end |
#healthcheck ⇒ Object
76 77 78 |
# File 'lib/mrsk/commander.rb', line 76 def healthcheck @healthcheck ||= Mrsk::Commands::Healthcheck.new(config) end |
#hosts ⇒ Object
31 32 33 |
# File 'lib/mrsk/commander.rb', line 31 def hosts specific_hosts || config.all_hosts end |
#primary_host ⇒ Object
27 28 29 |
# File 'lib/mrsk/commander.rb', line 27 def primary_host specific_hosts&.sole || config.primary_web_host end |
#prune ⇒ Object
64 65 66 |
# File 'lib/mrsk/commander.rb', line 64 def prune @prune ||= Mrsk::Commands::Prune.new(config) end |
#registry ⇒ Object
60 61 62 |
# File 'lib/mrsk/commander.rb', line 60 def registry @registry ||= Mrsk::Commands::Registry.new(config) end |
#reset ⇒ Object
Test-induced damage!
94 95 96 97 98 |
# File 'lib/mrsk/commander.rb', line 94 def reset @config = @config_file = @destination = @version = nil @app = @builder = @traefik = @registry = @prune = @auditor = nil @verbosity = :info end |
#specific_primary! ⇒ Object
19 20 21 |
# File 'lib/mrsk/commander.rb', line 19 def specific_primary! self.specific_hosts = [ config.primary_web_host ] end |
#specific_roles=(role_names) ⇒ Object
23 24 25 |
# File 'lib/mrsk/commander.rb', line 23 def specific_roles=(role_names) self.specific_hosts = config.roles.select { |r| role_names.include?(r.name) }.flat_map(&:hosts) if role_names.present? end |
#traefik ⇒ Object
56 57 58 |
# File 'lib/mrsk/commander.rb', line 56 def traefik @traefik ||= Mrsk::Commands::Traefik.new(config) end |
#traefik_hosts ⇒ Object
35 36 37 |
# File 'lib/mrsk/commander.rb', line 35 def traefik_hosts specific_hosts || config.traefik_hosts end |
#with_verbosity(level) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/mrsk/commander.rb', line 81 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 |