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.
-
#verbose ⇒ Object
Returns the value of attribute verbose.
-
#version ⇒ Object
Returns the value of attribute version.
Instance Method Summary collapse
- #accessory(name) ⇒ Object
- #accessory_hosts ⇒ Object
- #accessory_names ⇒ Object
- #app ⇒ Object
- #builder ⇒ Object
- #config ⇒ Object
- #hosts ⇒ Object
-
#initialize(config_file: nil, destination: nil, verbose: false) ⇒ Commander
constructor
A new instance of Commander.
- #primary_host ⇒ Object
- #prune ⇒ Object
- #registry ⇒ Object
- #specific_primary! ⇒ Object
- #specific_roles=(role_names) ⇒ Object
- #traefik ⇒ Object
- #traefik_hosts ⇒ Object
- #verbosity(level) ⇒ Object
Constructor Details
#initialize(config_file: nil, destination: nil, verbose: false) ⇒ Commander
Returns a new instance of Commander.
14 15 16 |
# File 'lib/mrsk/commander.rb', line 14 def initialize(config_file: nil, destination: nil, verbose: false) @config_file, @destination, @verbose = config_file, destination, verbose end |
Instance Attribute Details
#config_file ⇒ Object
Returns the value of attribute config_file.
12 13 14 |
# File 'lib/mrsk/commander.rb', line 12 def config_file @config_file end |
#destination ⇒ Object
Returns the value of attribute destination.
12 13 14 |
# File 'lib/mrsk/commander.rb', line 12 def destination @destination end |
#specific_hosts ⇒ Object
Returns the value of attribute specific_hosts.
25 26 27 |
# File 'lib/mrsk/commander.rb', line 25 def specific_hosts @specific_hosts end |
#verbose ⇒ Object
Returns the value of attribute verbose.
12 13 14 |
# File 'lib/mrsk/commander.rb', line 12 def verbose @verbose end |
#version ⇒ Object
Returns the value of attribute version.
12 13 14 |
# File 'lib/mrsk/commander.rb', line 12 def version @version end |
Instance Method Details
#accessory(name) ⇒ Object
76 77 78 |
# File 'lib/mrsk/commander.rb', line 76 def accessory(name) config.accessories.detect { |a| a.name == name } end |
#accessory_hosts ⇒ Object
47 48 49 |
# File 'lib/mrsk/commander.rb', line 47 def accessory_hosts specific_hosts || config.accessories.collect(&:host) end |
#accessory_names ⇒ Object
51 52 53 |
# File 'lib/mrsk/commander.rb', line 51 def accessory_names config.accessories&.collect(&:name) || [] end |
#app ⇒ Object
56 57 58 |
# File 'lib/mrsk/commander.rb', line 56 def app @app ||= Mrsk::Commands::App.new(config) end |
#builder ⇒ Object
60 61 62 |
# File 'lib/mrsk/commander.rb', line 60 def builder @builder ||= Mrsk::Commands::Builder.new(config) end |
#config ⇒ Object
18 19 20 21 22 23 |
# File 'lib/mrsk/commander.rb', line 18 def config @config ||= \ Mrsk::Configuration .create_from(config_file, destination: destination, version: cascading_version) .tap { |config| configure_sshkit_with(config) } end |
#hosts ⇒ Object
39 40 41 |
# File 'lib/mrsk/commander.rb', line 39 def hosts specific_hosts || config.all_hosts end |
#primary_host ⇒ Object
35 36 37 |
# File 'lib/mrsk/commander.rb', line 35 def primary_host specific_hosts&.sole || config.primary_web_host end |
#prune ⇒ Object
72 73 74 |
# File 'lib/mrsk/commander.rb', line 72 def prune @prune ||= Mrsk::Commands::Prune.new(config) end |
#registry ⇒ Object
68 69 70 |
# File 'lib/mrsk/commander.rb', line 68 def registry @registry ||= Mrsk::Commands::Registry.new(config) end |
#specific_primary! ⇒ Object
27 28 29 |
# File 'lib/mrsk/commander.rb', line 27 def specific_primary! self.specific_hosts = [ config.primary_web_host ] end |
#specific_roles=(role_names) ⇒ Object
31 32 33 |
# File 'lib/mrsk/commander.rb', line 31 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
64 65 66 |
# File 'lib/mrsk/commander.rb', line 64 def traefik @traefik ||= Mrsk::Commands::Traefik.new(config) end |
#traefik_hosts ⇒ Object
43 44 45 |
# File 'lib/mrsk/commander.rb', line 43 def traefik_hosts specific_hosts || config.traefik_hosts end |
#verbosity(level) ⇒ Object
81 82 83 84 85 86 87 |
# File 'lib/mrsk/commander.rb', line 81 def verbosity(level) old_level = SSHKit.config.output_verbosity SSHKit.config.output_verbosity = level yield ensure SSHKit.config.output_verbosity = old_level end |