hiera-router 0.2.3 → 0.2.5
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 -11
- 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: c260f8ab76b316611f8cfc8dd504abd1cc551ef8
|
4
|
+
data.tar.gz: 6243a808c495352baa3ac4fd0df35ddd565b299b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: eaa8cf281a46d1eae42d209a6d7ed52a3f7b94100de324435a6e79f27ea601ce3f0515ead9422aec405e90cd9629f47ec851bc344f6be0168d017bfb4a9b0b63
|
7
|
+
data.tar.gz: a2ae9d18a0f10b8f0b2094cc82494737f34514eb5b7d89af2f1c5b3765cd960d5979e46953629456830bfccfcfc0ff9c602dc4fb1f068415e9ff940de4e25469
|
@@ -67,29 +67,30 @@ class Hiera
|
|
67
67
|
return answer
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
71
|
-
|
72
|
-
puts path.join('>')
|
73
|
-
my_hash = hash
|
70
|
+
def recursive_key_from_hash(hash, path)
|
71
|
+
focus = hash
|
74
72
|
path.each do |key|
|
75
|
-
|
73
|
+
if focus.is_a?(Hash) and focus.include?(key)
|
74
|
+
focus = focus[key]
|
75
|
+
else
|
76
|
+
return nil
|
77
|
+
end
|
76
78
|
end
|
77
79
|
|
78
|
-
|
79
|
-
return my_hash
|
80
|
+
return focus
|
80
81
|
end
|
81
82
|
|
82
83
|
def parse_answer(data, scope, options, path = [])
|
83
84
|
if data.is_a?(Numeric) or data.is_a?(TrueClass) or data.is_a?(FalseClass)
|
84
85
|
return data
|
85
86
|
elsif data.is_a?(String)
|
86
|
-
return parse_string(data, scope, options)
|
87
|
+
return parse_string(data, scope, options, path)
|
87
88
|
elsif data.is_a?(Hash)
|
88
89
|
answer = {}
|
89
90
|
data.each_pair do |key, val|
|
90
91
|
interpolated_key = Backend.parse_string(key, scope)
|
91
92
|
subpath = path + [interpolated_key]
|
92
|
-
answer[interpolated_key] =
|
93
|
+
answer[interpolated_key] = parse_answer(val, scope, options, subpath)
|
93
94
|
end
|
94
95
|
|
95
96
|
return answer
|
@@ -103,7 +104,7 @@ class Hiera
|
|
103
104
|
end
|
104
105
|
end
|
105
106
|
|
106
|
-
def parse_string(data, scope, options)
|
107
|
+
def parse_string(data, scope, options, path = [])
|
107
108
|
if match = data.match(/^backend\[([^,]+)(?:,(.*))?\]$/)
|
108
109
|
backend_name, backend_parameters = match.captures
|
109
110
|
backend_options = options
|
@@ -116,7 +117,7 @@ class Hiera
|
|
116
117
|
result = data
|
117
118
|
end
|
118
119
|
Hiera.debug("[hiera-router] Call to '#{backend_name}' finished.")
|
119
|
-
return result
|
120
|
+
return recursive_key_from_hash(result, path)
|
120
121
|
else
|
121
122
|
Backend.parse_string(data, scope)
|
122
123
|
end
|