hiera-router 0.2.2 → 0.2.3

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: 8fafaff4f4c799dd687359d49d2ff3b945ce5a38
4
- data.tar.gz: f4dcb3f54d9f9c41664d4aea1e96daa5c5a2d00f
3
+ metadata.gz: f008fd079d6bf63f1a897eb53b1d42338152aa6b
4
+ data.tar.gz: adcbbf85adce23472dc99cfcf36689711a9f26a9
5
5
  SHA512:
6
- metadata.gz: ccb322433f7dc7ba2afaa8c799b0a3fb6c684c557f645e5e75e2e916257eb9314f8888f1da8e0ee7d9636b87048589c7abea9c411295c0342009d38074d74494
7
- data.tar.gz: 8513e838ae89fd2a1313ad077f0c7a797680b6909644f0acd95ec5be77ba666abd4467d078ec72fb6dfff5a03849b95fd7d9b61ad336ad35542d85e8e1c026d1
6
+ metadata.gz: 7674d2308f350a7a1defddca3acf39025f1faf745dc9a9a18088366e815d25b091016ec20323b7dff84921bceee47f5a9870689e4472c40f548b5ecd4ba5a973
7
+ data.tar.gz: 4e208e39b5841e419d394ad4df518829a3db737844bd5cca2d878c6445fe1213ebbf04470057601a9eadf79a74a91c01b6703885141bf4fd3314c451ff3d88e9
@@ -67,7 +67,19 @@ class Hiera
67
67
  return answer
68
68
  end
69
69
 
70
- def parse_answer(data, scope, options)
70
+ def hash_key(hash, path)
71
+ puts hash.inspect
72
+ puts path.join('>')
73
+ my_hash = hash
74
+ path.each do |key|
75
+ my_hash = my_hash[key] if my_hash.include?(key)
76
+ end
77
+
78
+ puts "result: #{my_hash}"
79
+ return my_hash
80
+ end
81
+
82
+ def parse_answer(data, scope, options, path = [])
71
83
  if data.is_a?(Numeric) or data.is_a?(TrueClass) or data.is_a?(FalseClass)
72
84
  return data
73
85
  elsif data.is_a?(String)
@@ -76,7 +88,8 @@ class Hiera
76
88
  answer = {}
77
89
  data.each_pair do |key, val|
78
90
  interpolated_key = Backend.parse_string(key, scope)
79
- answer[interpolated_key] = parse_answer(val, scope, options)
91
+ subpath = path + [interpolated_key]
92
+ answer[interpolated_key] = hash_key(parse_answer(val, scope, options, subpath), subpath)
80
93
  end
81
94
 
82
95
  return answer
@@ -99,7 +112,8 @@ class Hiera
99
112
  if backend = backends[backend_name]
100
113
  result = backend.lookup(backend_options[:key], backend_options[:scope], nil, backend_options[:resolution_type])
101
114
  else
102
- raise "Backend '#{backend_name}' was not configured"
115
+ Hiera.warn "Backend '#{backend_name}' was not configured; returning the data as-is."
116
+ result = data
103
117
  end
104
118
  Hiera.debug("[hiera-router] Call to '#{backend_name}' finished.")
105
119
  return result
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hiera-router
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jo Vandeginste
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-06-24 00:00:00.000000000 Z
12
+ date: 2016-07-04 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: |
15
15
  This hiera backend replaces the default yaml backend, but will resend queries to other hiera backends based on the value returned by the yaml files.