Method: MotherBrain::Cli::SubCommand::Component.fabricate

Defined in:
lib/mb/cli/sub_command/component.rb

.fabricate(component) ⇒ SubCommand::Component

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Parameters:

Returns:



23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/mb/cli/sub_command/component.rb', line 23

def fabricate(component)
  environment = CliGateway.invoked_opts[:environment]

  Class.new(self) do
    set_component(component)

    component.commands.each do |command|
      define_task(command)
    end

    desc("nodes", "List all nodes grouped by Group")
    define_method(:nodes) do
      ui.say "Listing nodes for '#{component.name}' in '#{environment}':"
      nodes = component.nodes(environment).each do |group, nodes|
        nodes.collect! { |node| "#{node.public_hostname} (#{node.public_ipv4})" }
      end
      ui.say nodes.to_yaml
    end
  end
end