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 +4 -4
- data/README.md +0 -1
- data/lib/hiera/backend/yamll_backend.rb +14 -5
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e82ddbe3f7f7899124b06d0716ef1293cb96e5c9
|
4
|
+
data.tar.gz: 06079d18c491c83c0e583d16ae7d1162076b4083
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a3dc8f53705272d38954b79058a533f53588539b194f230f82336aba2a64b761eddd4c6edf59eabb5ee4064f20b96a438e4a31c2f9474f7c0eb802df9afa3ef8
|
7
|
+
data.tar.gz: 79427991e49ab38d8af922abfd947a40336a78f9ed5c3ca3d83c20ec05c74817d1f1d0c0de9605e08f55c22528d06a485cc815d870c5eaa62d77baf519fcd7bb
|
data/README.md
CHANGED
@@ -2,7 +2,7 @@ require 'hiera'
|
|
2
2
|
class Hiera
|
3
3
|
module Backend
|
4
4
|
class Yamll_backend
|
5
|
-
VERSION = "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
|
-
|
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
|
-
|
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
|
-
|
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.
|
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-
|
11
|
+
date: 2016-10-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: pry
|