hiera-yamll 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d51ba2ee6563b10745b2c612f70eaa8d64aaa15c
4
- data.tar.gz: c4b824ce43c0b2bd20ac57a94103d9ff9a84f80d
3
+ metadata.gz: e82ddbe3f7f7899124b06d0716ef1293cb96e5c9
4
+ data.tar.gz: 06079d18c491c83c0e583d16ae7d1162076b4083
5
5
  SHA512:
6
- metadata.gz: 71daa83a6d501cfc964074df82bf78bf63bafe61c205103ca566934cdc8f9c5d8008f639e8aa4881964027ea305d104afa87a5178aa8fac31f09e48bb84bc0e4
7
- data.tar.gz: 2969f1e526ac8bc57a448d137bb42d1918b8f196e4660250e6a66131059e712acdefc06beb4ad9620a1c4284baf987587fa6ec0192c4d8954f1dfc1bf1884a29
6
+ metadata.gz: a3dc8f53705272d38954b79058a533f53588539b194f230f82336aba2a64b761eddd4c6edf59eabb5ee4064f20b96a438e4a31c2f9474f7c0eb802df9afa3ef8
7
+ data.tar.gz: 79427991e49ab38d8af922abfd947a40336a78f9ed5c3ca3d83c20ec05c74817d1f1d0c0de9605e08f55c22528d06a485cc815d870c5eaa62d77baf519fcd7bb
data/README.md CHANGED
@@ -20,7 +20,6 @@ Or install it yourself as:
20
20
  $ gem install hiera-yamll
21
21
 
22
22
  ## Usage
23
-
24
23
  Install this gem along side your hiera installation in order to use this backend.
25
24
 
26
25
  ## Development
@@ -2,7 +2,7 @@ require 'hiera'
2
2
  class Hiera
3
3
  module Backend
4
4
  class Yamll_backend
5
- VERSION = "0.2.0"
5
+ VERSION = "0.3.0"
6
6
  # This is left blank because we are hacking hiera backend logic
7
7
  # to get around a limitation of hiera where you cannot have
8
8
  # multiple backends of the same type.
@@ -15,12 +15,12 @@ class Hiera
15
15
  @cache = cache || Filecache.new
16
16
  end
17
17
 
18
- def lookup(key, scope, order_override, resolution_type, context)
18
+ # context is for newer versions of hiera and we will use that variable as a way to determine versions of hiera
19
+ def lookup(key, scope, order_override, resolution_type, context=nil)
19
20
  answer = nil
20
21
  found = false
21
22
 
22
23
  Hiera.debug("Looking up #{key} in YAMLL backend")
23
-
24
24
  Backend.datasourcefiles(:yamll, scope, "yaml", order_override) do |source, yamlfile|
25
25
  data = @cache.read_file(yamlfile, Hash) do |data|
26
26
  YAML.load(data) || {}
@@ -41,7 +41,12 @@ class Hiera
41
41
  # the array
42
42
  #
43
43
  # for priority searches we break after the first found data item
44
- new_answer = Backend.parse_answer(data[key], scope, {}, context)
44
+ if context
45
+ # versions of newer hiera use a context
46
+ new_answer = Backend.parse_answer(data[key], scope, {}, context)
47
+ else
48
+ new_answer = Backend.parse_answer(data[key], scope, {})
49
+ end
45
50
  case resolution_type.is_a?(Hash) ? :hash : resolution_type
46
51
  when :array
47
52
  raise Exception, "Hiera type mismatch for key '#{key}': expected Array and got #{new_answer.class}" unless new_answer.kind_of? Array or new_answer.kind_of? String
@@ -50,7 +55,11 @@ class Hiera
50
55
  when :hash
51
56
  raise Exception, "Hiera type mismatch for key '#{key}': expected Hash and got #{new_answer.class}" unless new_answer.kind_of? Hash
52
57
  answer ||= {}
53
- answer = Backend.merge_answer(new_answer, answer, resolution_type)
58
+ if context
59
+ answer = Backend.merge_answer(new_answer, answer, resolution_type)
60
+ else
61
+ answer = Backend.merge_answer(new_answer, answer)
62
+ end
54
63
  else
55
64
  answer = new_answer
56
65
  break
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiera-yamll
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Corey Osman
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2016-10-06 00:00:00.000000000 Z
11
+ date: 2016-10-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: pry