Class: Chef::PolicyBuilder::Policyfile::RunListExpansionIsh

Inherits:
Struct
  • Object
show all
Defined in:
lib/chef/policy_builder/policyfile.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#recipesObject

Returns the value of attribute recipes

Returns:

  • (Object)

    the current value of recipes


43
44
45
# File 'lib/chef/policy_builder/policyfile.rb', line 43

def recipes
  @recipes
end

#rolesObject

Returns the value of attribute roles

Returns:

  • (Object)

    the current value of roles


43
44
45
# File 'lib/chef/policy_builder/policyfile.rb', line 43

def roles
  @roles
end

Instance Method Details

#to_hObject Also known as: to_hash

Implementing the parts of the RunListExpansion interface we need to properly send this through to events.run_list_expanded as it is expecting a RunListExpansion object.


48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'lib/chef/policy_builder/policyfile.rb', line 48

def to_h
  # It looks like version only gets populated in the expanded_run_list when
  # using a little used feature of roles to version lock cookbooks, so
  # version is not reliable in here anyway (places like Automate UI are
  # not getting version out of here.
  #
  # Skipped will always be false as it can only be true when two expanded
  # roles contain the same recipe.
  expanded_run_list = recipes.map do |r|
    { type: "recipe", name: r, skipped: false, version: nil }
  end
  data_collector_hash = {}
  data_collector_hash[:id] = "_policy_node"
  data_collector_hash[:run_list] = expanded_run_list
  data_collector_hash
end

#to_json(*opts) ⇒ Object


67
68
69
# File 'lib/chef/policy_builder/policyfile.rb', line 67

def to_json(*opts)
  to_h.to_json(*opts)
end