Please review pull request #32: Differentiate between unique and non-unique array search opened by (Preston4tw)

Description:

A small patch to add an option to allow for non-unique array search by default, and a different unique array search.

  • Opened: Sat Feb 11 04:25:06 UTC 2012
  • Based on: puppetlabs:master (81cd80cfa9c008665a229d0d034186c3a8692bb8)
  • Requested merge: Preston4tw:master (2964e51d436744ecd406cb810771b19d6bc3a9e2)

Diff follows:

diff --git a/bin/hiera b/bin/hiera
index cc4c8a8..2357275 100755
--- a/bin/hiera
+++ b/bin/hiera
@@ -116,6 +116,10 @@ OptionParser.new do |opts|
     options[:resolution_type] = :array
   end
 
+  opts.on("--unique", "-u", "Unique array search") do
+    options[:resolution_type] = :unique_array
+  end
+
   opts.on("--hash", "-h", "Hash search") do
     options[:resolution_type] = :hash
   end
diff --git a/lib/hiera/backend.rb b/lib/hiera/backend.rb
index 3f593b1..cfd1a7e 100644
--- a/lib/hiera/backend.rb
+++ b/lib/hiera/backend.rb
@@ -129,6 +129,8 @@ def parse_answer(data, scope, extra_data={})
       def resolve_answer(answer, resolution_type)
         case resolution_type
         when :array
+          [answer].flatten.compact
+        when :unique_array
           [answer].flatten.uniq.compact
         when :hash
           answer # Hash structure should be preserved

    

--
You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to puppet-dev@googlegroups.com.
To unsubscribe from this group, send email to puppet-dev+unsubscr...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.

Reply via email to