Permalink
Browse files

Add support for array lookups

  • Loading branch information...
1 parent faff0a7 commit 567a03595b7bac21feeab60d631869e95b96a6e3 @adrienthebo adrienthebo committed Dec 6, 2012
Showing with 12 additions and 4 deletions.
  1. +12 −4 lib/hiera/backend/file_backend.rb
@@ -23,13 +23,21 @@ def lookup(key, scope, order_override, resolution_type)
unless abs_path.index(abs_datadir) == 0
raise Exception, "Hiera File backend: key lookup outside of datadir '#{key}'"
end
+
next unless File.exist?(abs_path)
data = File.read(abs_path)
- next unless data
- answer = data
- break
+
+ case resolution_type
+ when :array
+ answer ||= []
+ answer << Backend.parse_answer(data, scope)
+ else
+ answer = Backend.parse_answer(data, scope)
+ break
+ end
end
- return answer
+
+ answer
end
end
end

0 comments on commit 567a035

Please sign in to comment.