Please review pull request #36: Bug #12122 fix opened by (carlasouza)
Description:
The lookup method cannot return nil in case there isn't an available answer. Instead, an empty data structure ("", [] or {}) will be returned. Also, calling hiera_array and hiera_hash should return all results from all backends.
- Opened: Sat Mar 10 15:13:37 UTC 2012
- Based on: puppetlabs:master (4b2ae058e9a60532886158af1ef8d7ce08118653)
- Requested merge: carlasouza:560e2f2d96990cd912f3794e687f76a1f8772c6b (560e2f2d96990cd912f3794e687f76a1f8772c6b)
Diff follows:
diff --git a/lib/hiera/backend.rb b/lib/hiera/backend.rb
index e0c7c85..53389a4 100644
--- a/lib/hiera/backend.rb
+++ b/lib/hiera/backend.rb
@@ -157,16 +157,25 @@ def lookup(key, default, scope, order_override, resolution_type)
Config[:backends].each do |backend|
if constants.include?("#{backend.capitalize}_backend") || constants.include?("#{backend.capitalize}_backend".to_sym)
@backends[backend] ||= Backend.const_get("#{backend.capitalize}_backend").new
- answer = @backends[backend].lookup(key, scope, order_override, resolution_type)
-
- break if answer
+ this_answ = @backends[backend].lookup(key, scope, order_override, resolution_type)
+ case resolution_type
+ when :priority
+ answer = this_answ
+ break if answer
+ when :array
+ answer ||= []
+ answer << this_answ
+ when :hash
+ answer ||= {}
+ answer = this_answ.merge answer
+ end
end
end
answer = resolve_answer(answer, resolution_type)
answer = parse_string(default, scope) if answer.nil?
- return default if answer == empty_answer(resolution_type)
+ return default if answer == empty_answer(resolution_type) unless default.nil?
return answer
end
end
-- You received this message because you are subscribed to the Google Groups "Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to [email protected].
For more options, visit this group at http://groups.google.com/group/puppet-dev?hl=en.
