Sha256: ce736bada7e4514cdd1e92f3d513c95ff71169ec7ff4e41800ef4a123d3abd48

Contents?: true

Size: 614 Bytes

Versions: 73

Compression:

Stored size: 614 Bytes

Contents

# frozen_string_literal: true

# Aggregates the key/value pairs in the results of a ResultSet into a hash
# mapping the keys to a hash of each distinct value and the list of nodes
# returning that value for the key.
Puppet::Functions.create_function(:'aggregate::nodes') do
  dispatch :aggregate_nodes do
    param 'ResultSet', :resultset
  end

  def aggregate_nodes(resultset)
    resultset.each_with_object({}) do |result, agg|
      result.value.each do |key, val|
        agg[key] ||= {}
        agg[key][val.to_s] ||= []
        agg[key][val.to_s] << result.target.name
      end
      agg
    end
  end
end

Version data entries

73 entries across 73 versions & 1 rubygems

Version Path
bolt-0.21.1 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
bolt-0.21.0 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
bolt-0.20.7 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
bolt-0.20.6 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
bolt-0.20.5 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
bolt-0.20.3 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
bolt-0.20.2 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
bolt-0.20.0 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
bolt-0.19.1 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
bolt-0.19.0 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
bolt-0.18.2 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
bolt-0.18.1 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb
bolt-0.18.0 modules/aggregate/lib/puppet/functions/aggregate/nodes.rb