[Pkg-puppet-devel] [facter] 177/352: (FACT-237) Define default aggregate action

Stig Sandbeck Mathisen ssm at debian.org
Sun Apr 6 22:21:43 UTC 2014


This is an automated email from the git hooks/post-receive script.

ssm pushed a commit to branch master
in repository facter.

commit 083e0aa86766612161d6af965d5e5bba6f5e6942
Author: Adrien Thebo <git at somethingsinistral.net>
Date:   Fri Jan 17 09:49:20 2014 -0800

    (FACT-237) Define default aggregate action
---
 lib/facter/core/aggregate.rb | 21 +++++++++++++++++++--
 1 file changed, 19 insertions(+), 2 deletions(-)

diff --git a/lib/facter/core/aggregate.rb b/lib/facter/core/aggregate.rb
index ff199fc..99f3f72 100644
--- a/lib/facter/core/aggregate.rb
+++ b/lib/facter/core/aggregate.rb
@@ -162,10 +162,27 @@ class Facter::Core::Aggregate
     results
   end
 
-  # Process the results of all chunks with the aggregate block and return the results.
+  # Process the results of all chunks with the aggregate block and return the
+  # results. If no aggregate block has been specified, fall back to deep
+  # merging the given data structure
+  #
+  # @param results [Hash<Symbol, Object>] A hash of chunk names and the output
+  #   of that chunk.
   # @return [Object]
   def aggregate_results(results)
-    @aggregate.call(results)
+    if @aggregate
+      @aggregate.call(results)
+    else
+      default_aggregate(results)
+    end
+  end
+
+  def default_aggregate(results)
+    Facter::Util::Values.deep_merge(results.keys)
+  rescue Facter::Util::Values::DeepMergeError => e
+    raise ArgumentError, "No aggregate block specified and could not deep merge" +
+      " all chunks, either specify an aggregate block or ensure that all chunks" +
+      " return deep mergable structures. (Original error: #{e.message})", e.backtrace
   end
 
   # Order chunks based on their dependencies

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-puppet/facter.git



More information about the Pkg-puppet-devel mailing list