hiera-router 0.5.1 → 0.5.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/hiera/backend/router_backend.rb +12 -3
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8acc6c75c3de393f31c3354966b5dcbf57e1fea5
|
4
|
+
data.tar.gz: d0067460a22e3eef04bfc901a909b1f570986a71
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 01b9ef533ad0a1b2fc229f2e10b0b0cc7f2ce79f7da8d5f904a304bba36a7d862b6b42fd91ca5446f024e6c7431bf95c6250c9c632bd507196d38c28779dd3c4
|
7
|
+
data.tar.gz: 9369764493189bfb644e2c382e247eb55c26c6666b45bb71862d1f3f6da63aaa93ccbc1599446a8323ff9c560b4a03d2c7d08250ee504aa744b088a73e7aed98
|
@@ -1,5 +1,6 @@
|
|
1
1
|
require 'hiera/filecache'
|
2
2
|
require 'yaml'
|
3
|
+
require 'pry'
|
3
4
|
|
4
5
|
class Hiera
|
5
6
|
class Config
|
@@ -62,15 +63,18 @@ class Hiera
|
|
62
63
|
|
63
64
|
Hiera.debug("[hiera-router] hiera router initialized")
|
64
65
|
end
|
65
|
-
def lookup(
|
66
|
+
def lookup(lookup_key, scope, order_override, resolution_type)
|
66
67
|
options = {
|
67
68
|
:fqdn => scope['fqdn'],
|
68
69
|
:scope => scope,
|
69
|
-
:
|
70
|
+
:lookup_key => lookup_key,
|
70
71
|
:order_override => order_override,
|
71
72
|
:resolution_type => resolution_type,
|
72
73
|
}
|
73
74
|
|
75
|
+
key_path = Hiera::Util.split_key(lookup_key)
|
76
|
+
key = key_path.shift
|
77
|
+
|
74
78
|
cache_key = options.to_s
|
75
79
|
cached_value = @bigcache[cache_key]
|
76
80
|
if cached_value
|
@@ -78,7 +82,7 @@ class Hiera
|
|
78
82
|
end
|
79
83
|
answer = nil
|
80
84
|
|
81
|
-
Hiera.debug("[hiera-router] Looking up #{key} in yaml backend")
|
85
|
+
Hiera.debug("[hiera-router] Looking up #{key} in yaml backend (and then return path #{key_path.inspect})")
|
82
86
|
|
83
87
|
Backend.datasources(scope, order_override) do |source|
|
84
88
|
yaml_file = Backend.datafile(:router, scope, source, 'yaml') || next
|
@@ -116,6 +120,11 @@ class Hiera
|
|
116
120
|
end
|
117
121
|
end
|
118
122
|
|
123
|
+
while e = key_path.shift
|
124
|
+
raise Exception, "Hiera subkey '#{e}' not found" unless answer.include?(e)
|
125
|
+
answer = answer[e]
|
126
|
+
end
|
127
|
+
|
119
128
|
@bigcache[cache_key] = {
|
120
129
|
:value => answer,
|
121
130
|
:time => Time.now,
|