Class: MotherBrain::Gear::Service::ActionRunner Private

Inherits:
Object
  • Object
show all
Includes:
MB::Mixin::Services
Defined in:
lib/mb/gears/service/action_runner.rb

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

Defined Under Namespace

Classes: CleanRoom

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(environment, nodes, &block) ⇒ ActionRunner

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.

Returns a new instance of ActionRunner.

Parameters:

  • environment (String)
  • nodes (Array<Ridley::Node>)


17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/mb/gears/service/action_runner.rb', line 17

def initialize(environment, nodes, &block)
  @environment = environment
  @nodes       = Array(nodes)

  @environment_attributes = Array.new
  @node_attributes        = Array.new
  @toggle_callbacks       = Array.new

  if block_given?
    dsl_eval(&block)
  end
end

Instance Attribute Details

#environmentObject (readonly)

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.



8
9
10
# File 'lib/mb/gears/service/action_runner.rb', line 8

def environment
  @environment
end

#environment_attributesObject (readonly)

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.



12
13
14
# File 'lib/mb/gears/service/action_runner.rb', line 12

def environment_attributes
  @environment_attributes
end

#node_attributesObject (readonly)

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.



13
14
15
# File 'lib/mb/gears/service/action_runner.rb', line 13

def node_attributes
  @node_attributes
end

#nodesObject (readonly)

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.



9
10
11
# File 'lib/mb/gears/service/action_runner.rb', line 9

def nodes
  @nodes
end

#service_recipeObject (readonly)

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.



11
12
13
# File 'lib/mb/gears/service/action_runner.rb', line 11

def service_recipe
  @service_recipe
end

#toggle_callbacksObject (readonly)

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.



10
11
12
# File 'lib/mb/gears/service/action_runner.rb', line 10

def toggle_callbacks
  @toggle_callbacks
end

Instance Method Details

#add_environment_attribute(key, value, options = {}) ⇒ Object

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.

Set an environment level attribute to the given value. The key is represented by a dotted path.

Parameters:

  • key (String)
  • value (Object)
  • options (Hash) (defaults to: {})

    a customizable set of options

Options Hash (options):

  • :toggle (Boolean) — default: false

    set this environment attribute only for a single chef run



47
48
49
# File 'lib/mb/gears/service/action_runner.rb', line 47

def add_environment_attribute(key, value, options = {})
  @environment_attributes << { key: key, value: value, options: options }
end

#add_node_attribute(key, value, options) ⇒ Object

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.

Set a node level attribute on all nodes for this action to the given value. The key is represented by a dotted path.

Parameters:

  • key (String)
  • value (Object)
  • options (Hash)

    a customizable set of options

Options Hash (options):

  • :toggle (Boolean) — default: false

    set this node attribute only for a single chef run



59
60
61
# File 'lib/mb/gears/service/action_runner.rb', line 59

def add_node_attribute(key, value, options)
  @node_attributes << { key: key, value: value, options: options }
end

#reset(job) ⇒ Object

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.



30
31
32
# File 'lib/mb/gears/service/action_runner.rb', line 30

def reset(job)
  toggle_callbacks.concurrent_map { |callback| callback.call(job) }
end

#run(job) ⇒ Object

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.



34
35
36
37
# File 'lib/mb/gears/service/action_runner.rb', line 34

def run(job)
  set_node_attributes(job)
  set_environment_attributes(job)
end

#set_service_recipe(recipe) ⇒ Object

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.



63
64
65
# File 'lib/mb/gears/service/action_runner.rb', line 63

def set_service_recipe(recipe)
  @service_recipe = recipe
end